Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Can someone provide an example of using the @IdBag annotation in Elver...
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #84858 is a reply to message #84800] |
Fri, 25 May 2007 00:27   |
Eclipse User |
|
|
|
The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
But I am not sure if this will solve your problem. The hibernate docs say this about it (section 11.3):
Note that, in the current implementation, only one collection role may be fetched in a query
(everything else would be non-performant). Note also that the fetch construct may not be used in
queries called using scroll() or iterate(). Finally, note that full join fetch and right join fetch
are not meaningful.
Afaik the join behavior of an idbag is the same as for a bag. It is more the update and insert
behavior which is better.
gr. Martin
Michael Kanaley wrote:
> What is the syntax of the annotation?
> I have attached an ecore as an example that is working with the "refs"
> EAttribute of SomeClass using bags. I would like it to use IdBags instead.
>
> Also, as a side note, the real problem that I am trying to work around is
> the following Hibernate exception when left joins on multiple bag attributes
> are done.
> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
> bags".
> Will switching to idbags fix this issue?
>
> Thanks,
> -mike
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #84919 is a reply to message #84858] |
Fri, 25 May 2007 10:26   |
Eclipse User |
|
|
|
Hi Martin,
Sorry it was not clear from my first email but setting the @IdBag
annotation does not work.
Simply add the @IdBag annotation to the example I sent in the beginning. The
mapping generated is:
<idbag name="refs" table="someclass_someotherclass" lazy="true"
cascade="all,delete-orphan">
<collection-id column="ID" type="long">
<generator class="increment"/>
</collection-id>
<key/>
<many-to-many entity-name="SomeOtherClass" unique="false"/>
</idbag>
This does not look right but any attempt to set something does not work. Is
there an @IdBag test suite I can look at?
And the exception thrown is:
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: executing flush
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: registering flush begin
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: Inserting collection: [SomeClass.refs#1]
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: fetching initial value: select max(ID) from someclass_someotherclass
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
0)
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: select max(ID) from someclass_someotherclass
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: preparing statement
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: first free id: 1
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: about to close PreparedStatement (open PreparedStatements: 1,
globally: 1)
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: closing statement
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
0)
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: preparing statement
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: could not insert collection: [SomeClass.refs#1] [insert into
someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
java.sql.SQLException: Column count does not match in statement [insert into
someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
at
org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
at
org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
at
org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
at
org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
at test.TestBag.test(TestBag.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
Also note that the Hibernate doc section you are referring to has changed to
14.3 for Hibernate 3.2.2 and it's content is slightly different.
http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
It no longer indicates that only one left joined collection is supported -
but in practice, I have seen it only work with one collection.
Thanks,
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f35oj1$irq$1@build.eclipse.org...
> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
> But I am not sure if this will solve your problem. The hibernate docs say
> this about it (section 11.3):
> Note that, in the current implementation, only one collection role may be
> fetched in a query (everything else would be non-performant). Note also
> that the fetch construct may not be used in queries called using scroll()
> or iterate(). Finally, note that full join fetch and right join fetch are
> not meaningful.
>
> Afaik the join behavior of an idbag is the same as for a bag. It is more
> the update and insert behavior which is better.
>
> gr. Martin
>
> Michael Kanaley wrote:
>> What is the syntax of the annotation?
>> I have attached an ecore as an example that is working with the "refs"
>> EAttribute of SomeClass using bags. I would like it to use IdBags
>> instead.
>>
>> Also, as a side note, the real problem that I am trying to work around is
>> the following Hibernate exception when left joins on multiple bag
>> attributes are done.
>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>> bags".
>> Will switching to idbags fix this issue?
>>
>> Thanks,
>> -mike
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #85089 is a reply to message #84919] |
Fri, 25 May 2007 14:34   |
Eclipse User |
|
|
|
Hi Mike,
The mapping looks fine afaics. How many (and which) columns does the someclass_someotherclass table
have?
gr. Martin
Michael Kanaley wrote:
> Hi Martin,
> Sorry it was not clear from my first email but setting the @IdBag
> annotation does not work.
> Simply add the @IdBag annotation to the example I sent in the beginning. The
> mapping generated is:
> <idbag name="refs" table="someclass_someotherclass" lazy="true"
> cascade="all,delete-orphan">
>
> <collection-id column="ID" type="long">
>
> <generator class="increment"/>
>
> </collection-id>
>
> <key/>
>
> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>
> </idbag>
>
> This does not look right but any attempt to set something does not work. Is
> there an @IdBag test suite I can look at?
>
> And the exception thrown is:
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: executing flush
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: registering flush begin
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: Inserting collection: [SomeClass.refs#1]
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: fetching initial value: select max(ID) from someclass_someotherclass
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
> 0)
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: select max(ID) from someclass_someotherclass
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: preparing statement
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: first free id: 1
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: about to close PreparedStatement (open PreparedStatements: 1,
> globally: 1)
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: closing statement
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
> 0)
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: preparing statement
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: could not insert collection: [SomeClass.refs#1] [insert into
> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>
> java.sql.SQLException: Column count does not match in statement [insert into
> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>
> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>
> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>
> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>
> at
> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>
> at
> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>
> at
> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>
> at
> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>
> at test.TestBag.test(TestBag.java:97)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>
> at java.lang.reflect.Method.invoke(Unknown Source)
>
> at junit.framework.TestCase.runTest(TestCase.java:154)
>
> at junit.framework.TestCase.runBare(TestCase.java:127)
>
> at junit.framework.TestResult$1.protect(TestResult.java:106)
>
> at junit.framework.TestResult.runProtected(TestResult.java:124)
>
> at junit.framework.TestResult.run(TestResult.java:109)
>
> at junit.framework.TestCase.run(TestCase.java:118)
>
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>
> at junit.framework.TestSuite.run(TestSuite.java:203)
>
> at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>
>
> Also note that the Hibernate doc section you are referring to has changed to
> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
> It no longer indicates that only one left joined collection is supported -
> but in practice, I have seen it only work with one collection.
>
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f35oj1$irq$1@build.eclipse.org...
>> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
>> But I am not sure if this will solve your problem. The hibernate docs say
>> this about it (section 11.3):
>> Note that, in the current implementation, only one collection role may be
>> fetched in a query (everything else would be non-performant). Note also
>> that the fetch construct may not be used in queries called using scroll()
>> or iterate(). Finally, note that full join fetch and right join fetch are
>> not meaningful.
>>
>> Afaik the join behavior of an idbag is the same as for a bag. It is more
>> the update and insert behavior which is better.
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> What is the syntax of the annotation?
>>> I have attached an ecore as an example that is working with the "refs"
>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>> instead.
>>>
>>> Also, as a side note, the real problem that I am trying to work around is
>>> the following Hibernate exception when left joins on multiple bag
>>> attributes are done.
>>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>>> bags".
>>> Will switching to idbags fix this issue?
>>>
>>> Thanks,
>>> -mike
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #85104 is a reply to message #85089] |
Fri, 25 May 2007 16:48   |
Eclipse User |
|
|
|
The attached image indicates that there are only 2 generated, ID and ELT.
That seems right - why does the Teneo commit fail?
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f37a8j$38d$2@build.eclipse.org...
> Hi Mike,
> The mapping looks fine afaics. How many (and which) columns does the
> someclass_someotherclass table
> have?
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Hi Martin,
>> Sorry it was not clear from my first email but setting the @IdBag
>> annotation does not work.
>> Simply add the @IdBag annotation to the example I sent in the beginning.
>> The
>> mapping generated is:
>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>> cascade="all,delete-orphan">
>>
>> <collection-id column="ID" type="long">
>>
>> <generator class="increment"/>
>>
>> </collection-id>
>>
>> <key/>
>>
>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>
>> </idbag>
>>
>> This does not look right but any attempt to set something does not work.
>> Is
>> there an @IdBag test suite I can look at?
>>
>> And the exception thrown is:
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: executing flush
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: registering flush begin
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: Inserting collection: [SomeClass.refs#1]
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: fetching initial value: select max(ID) from
>> someclass_someotherclass
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>> globally:
>> 0)
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: select max(ID) from someclass_someotherclass
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: preparing statement
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: first free id: 1
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>> globally: 1)
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: closing statement
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>> globally:
>> 0)
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: preparing statement
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>
>> java.sql.SQLException: Column count does not match in statement [insert
>> into
>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>
>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>
>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>
>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>
>> at
>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>
>> at
>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>
>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>
>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>
>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>
>> at
>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>
>> at
>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>
>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>
>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>
>> at
>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>
>> at test.TestBag.test(TestBag.java:97)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>
>> at java.lang.reflect.Method.invoke(Unknown Source)
>>
>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>
>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>
>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>
>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>
>> at junit.framework.TestResult.run(TestResult.java:109)
>>
>> at junit.framework.TestCase.run(TestCase.java:118)
>>
>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>
>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>
>>
>> Also note that the Hibernate doc section you are referring to has changed
>> to
>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>> It no longer indicates that only one left joined collection is
>> supported -
>> but in practice, I have seen it only work with one collection.
>>
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:f35oj1$irq$1@build.eclipse.org...
>>> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
>>> But I am not sure if this will solve your problem. The hibernate docs
>>> say
>>> this about it (section 11.3):
>>> Note that, in the current implementation, only one collection role may
>>> be
>>> fetched in a query (everything else would be non-performant). Note also
>>> that the fetch construct may not be used in queries called using
>>> scroll()
>>> or iterate(). Finally, note that full join fetch and right join fetch
>>> are
>>> not meaningful.
>>>
>>> Afaik the join behavior of an idbag is the same as for a bag. It is more
>>> the update and insert behavior which is better.
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> What is the syntax of the annotation?
>>>> I have attached an ecore as an example that is working with the "refs"
>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>> instead.
>>>>
>>>> Also, as a side note, the real problem that I am trying to work around
>>>> is
>>>> the following Hibernate exception when left joins on multiple bag
>>>> attributes are done.
>>>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>>>> bags".
>>>> Will switching to idbags fix this issue?
>>>>
>>>> Thanks,
>>>> -mike
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Tel: +31 (0)84 420 2397
>>> Fax: +31 (0)84 225 9307
>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>> Web: www.springsite.com - www.elver.org
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #85121 is a reply to message #85104] |
Fri, 25 May 2007 17:33   |
Eclipse User |
|
|
|
There should be three, two for the joins to both tables (parent and child) (id and elt) and one for
the id of the idbag entry itself (ID). My guess is that there is a nameclash between the id fields.
Although one is lowercase (id) and the other uppercase (ID) hsqldb does not seem to make a difference.
I encountered the same thing in a customer project I am doing right now. I have added an option to
set the name of the idbag id element and this solved the issue for me.
However, it will take a few weeks before I do a new release with this solution.
gr. Martin
Michael Kanaley wrote:
> The attached image indicates that there are only 2 generated, ID and ELT.
> That seems right - why does the Teneo commit fail?
> -mike
>
>
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f37a8j$38d$2@build.eclipse.org...
>> Hi Mike,
>> The mapping looks fine afaics. How many (and which) columns does the
>> someclass_someotherclass table
>> have?
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> Hi Martin,
>>> Sorry it was not clear from my first email but setting the @IdBag
>>> annotation does not work.
>>> Simply add the @IdBag annotation to the example I sent in the beginning.
>>> The
>>> mapping generated is:
>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>> cascade="all,delete-orphan">
>>>
>>> <collection-id column="ID" type="long">
>>>
>>> <generator class="increment"/>
>>>
>>> </collection-id>
>>>
>>> <key/>
>>>
>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>
>>> </idbag>
>>>
>>> This does not look right but any attempt to set something does not work.
>>> Is
>>> there an @IdBag test suite I can look at?
>>>
>>> And the exception thrown is:
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: executing flush
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: registering flush begin
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: fetching initial value: select max(ID) from
>>> someclass_someotherclass
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>> globally:
>>> 0)
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: select max(ID) from someclass_someotherclass
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: preparing statement
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: first free id: 1
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>> globally: 1)
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: closing statement
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>> globally:
>>> 0)
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: preparing statement
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>
>>> java.sql.SQLException: Column count does not match in statement [insert
>>> into
>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>
>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>
>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>
>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>
>>> at
>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>
>>> at
>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>
>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>
>>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>
>>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>
>>> at
>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>
>>> at
>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>
>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>
>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>
>>> at
>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>
>>> at test.TestBag.test(TestBag.java:97)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>
>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>
>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>
>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>
>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>
>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>
>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>
>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>
>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>
>>>
>>> Also note that the Hibernate doc section you are referring to has changed
>>> to
>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>> It no longer indicates that only one left joined collection is
>>> supported -
>>> but in practice, I have seen it only work with one collection.
>>>
>>> Thanks,
>>> -mike
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:f35oj1$irq$1@build.eclipse.org...
>>>> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
>>>> But I am not sure if this will solve your problem. The hibernate docs
>>>> say
>>>> this about it (section 11.3):
>>>> Note that, in the current implementation, only one collection role may
>>>> be
>>>> fetched in a query (everything else would be non-performant). Note also
>>>> that the fetch construct may not be used in queries called using
>>>> scroll()
>>>> or iterate(). Finally, note that full join fetch and right join fetch
>>>> are
>>>> not meaningful.
>>>>
>>>> Afaik the join behavior of an idbag is the same as for a bag. It is more
>>>> the update and insert behavior which is better.
>>>>
>>>> gr. Martin
>>>>
>>>> Michael Kanaley wrote:
>>>>> What is the syntax of the annotation?
>>>>> I have attached an ecore as an example that is working with the "refs"
>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>> instead.
>>>>>
>>>>> Also, as a side note, the real problem that I am trying to work around
>>>>> is
>>>>> the following Hibernate exception when left joins on multiple bag
>>>>> attributes are done.
>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>>>>> bags".
>>>>> Will switching to idbags fix this issue?
>>>>>
>>>>> Thanks,
>>>>> -mike
>>>> --
>>>>
>>>> With Regards, Martin Taal
>>>>
>>>> Springsite/Elver.org
>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>> The Netherlands
>>>> Tel: +31 (0)84 420 2397
>>>> Fax: +31 (0)84 225 9307
>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>> Web: www.springsite.com - www.elver.org
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #85442 is a reply to message #85121] |
Fri, 01 June 2007 07:46   |
Eclipse User |
|
|
|
Hi Martin,
Did you file a bug for this issue below. I am interested in this fix (for
the 0.7.5 releases) and want to track it so I know which version of Teneo it
is supported in.
Thanks,
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f37kn7$71f$1@build.eclipse.org...
> There should be three, two for the joins to both tables (parent and child)
> (id and elt) and one for the id of the idbag entry itself (ID). My guess
> is that there is a nameclash between the id fields. Although one is
> lowercase (id) and the other uppercase (ID) hsqldb does not seem to make a
> difference.
>
> I encountered the same thing in a customer project I am doing right now. I
> have added an option to set the name of the idbag id element and this
> solved the issue for me.
> However, it will take a few weeks before I do a new release with this
> solution.
>
> gr. Martin
>
> Michael Kanaley wrote:
>> The attached image indicates that there are only 2 generated, ID and ELT.
>> That seems right - why does the Teneo commit fail?
>> -mike
>>
>>
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:f37a8j$38d$2@build.eclipse.org...
>>> Hi Mike,
>>> The mapping looks fine afaics. How many (and which) columns does the
>>> someclass_someotherclass table
>>> have?
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> Hi Martin,
>>>> Sorry it was not clear from my first email but setting the @IdBag
>>>> annotation does not work.
>>>> Simply add the @IdBag annotation to the example I sent in the
>>>> beginning. The
>>>> mapping generated is:
>>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>>> cascade="all,delete-orphan">
>>>>
>>>> <collection-id column="ID" type="long">
>>>>
>>>> <generator class="increment"/>
>>>>
>>>> </collection-id>
>>>>
>>>> <key/>
>>>>
>>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>>
>>>> </idbag>
>>>>
>>>> This does not look right but any attempt to set something does not
>>>> work. Is
>>>> there an @IdBag test suite I can look at?
>>>>
>>>> And the exception thrown is:
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: executing flush
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: registering flush begin
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: fetching initial value: select max(ID) from
>>>> someclass_someotherclass
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>> globally:
>>>> 0)
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: select max(ID) from someclass_someotherclass
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: preparing statement
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: first free id: 1
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>>> globally: 1)
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: closing statement
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>> globally:
>>>> 0)
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?,
>>>> ?)
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: preparing statement
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>
>>>> java.sql.SQLException: Column count does not match in statement [insert
>>>> into
>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>
>>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>>
>>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>>
>>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>>
>>>> at
>>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>>
>>>> at
>>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>>
>>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>>
>>>> at
>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>>
>>>> at
>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>>
>>>> at
>>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>>
>>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>>
>>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>>
>>>> at
>>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>>
>>>> at test.TestBag.test(TestBag.java:97)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>
>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>
>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>
>>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>>
>>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>>
>>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>>
>>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>>
>>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>>
>>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>>
>>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>>
>>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>>
>>>>
>>>> Also note that the Hibernate doc section you are referring to has
>>>> changed to
>>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>>> It no longer indicates that only one left joined collection is
>>>> supported -
>>>> but in practice, I have seen it only work with one collection.
>>>>
>>>> Thanks,
>>>> -mike
>>>>
>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>> news:f35oj1$irq$1@build.eclipse.org...
>>>>> The syntax is: @IdBag (the source of the annotation is
>>>>> teneo.hibernate).
>>>>> But I am not sure if this will solve your problem. The hibernate docs
>>>>> say
>>>>> this about it (section 11.3):
>>>>> Note that, in the current implementation, only one collection role may
>>>>> be
>>>>> fetched in a query (everything else would be non-performant). Note
>>>>> also
>>>>> that the fetch construct may not be used in queries called using
>>>>> scroll()
>>>>> or iterate(). Finally, note that full join fetch and right join fetch
>>>>> are
>>>>> not meaningful.
>>>>>
>>>>> Afaik the join behavior of an idbag is the same as for a bag. It is
>>>>> more
>>>>> the update and insert behavior which is better.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Michael Kanaley wrote:
>>>>>> What is the syntax of the annotation?
>>>>>> I have attached an ecore as an example that is working with the
>>>>>> "refs"
>>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>>> instead.
>>>>>>
>>>>>> Also, as a side note, the real problem that I am trying to work
>>>>>> around is
>>>>>> the following Hibernate exception when left joins on multiple bag
>>>>>> attributes are done.
>>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch
>>>>>> multiple
>>>>>> bags".
>>>>>> Will switching to idbags fix this issue?
>>>>>>
>>>>>> Thanks,
>>>>>> -mike
>>>>> --
>>>>>
>>>>> With Regards, Martin Taal
>>>>>
>>>>> Springsite/Elver.org
>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>> The Netherlands
>>>>> Tel: +31 (0)84 420 2397
>>>>> Fax: +31 (0)84 225 9307
>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>> Web: www.springsite.com - www.elver.org
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Tel: +31 (0)84 420 2397
>>> Fax: +31 (0)84 225 9307
>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>> Web: www.springsite.com - www.elver.org
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #85472 is a reply to message #85442] |
Sat, 02 June 2007 00:53   |
Eclipse User |
|
|
|
Hi Mike,
I solved this in the 0.8.0 release. Please enter a bugzilla to get it also back into 0.7.5.
gr. Martin
Michael Kanaley wrote:
> Hi Martin,
> Did you file a bug for this issue below. I am interested in this fix (for
> the 0.7.5 releases) and want to track it so I know which version of Teneo it
> is supported in.
>
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f37kn7$71f$1@build.eclipse.org...
>> There should be three, two for the joins to both tables (parent and child)
>> (id and elt) and one for the id of the idbag entry itself (ID). My guess
>> is that there is a nameclash between the id fields. Although one is
>> lowercase (id) and the other uppercase (ID) hsqldb does not seem to make a
>> difference.
>>
>> I encountered the same thing in a customer project I am doing right now. I
>> have added an option to set the name of the idbag id element and this
>> solved the issue for me.
>> However, it will take a few weeks before I do a new release with this
>> solution.
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> The attached image indicates that there are only 2 generated, ID and ELT.
>>> That seems right - why does the Teneo commit fail?
>>> -mike
>>>
>>>
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:f37a8j$38d$2@build.eclipse.org...
>>>> Hi Mike,
>>>> The mapping looks fine afaics. How many (and which) columns does the
>>>> someclass_someotherclass table
>>>> have?
>>>>
>>>> gr. Martin
>>>>
>>>> Michael Kanaley wrote:
>>>>> Hi Martin,
>>>>> Sorry it was not clear from my first email but setting the @IdBag
>>>>> annotation does not work.
>>>>> Simply add the @IdBag annotation to the example I sent in the
>>>>> beginning. The
>>>>> mapping generated is:
>>>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>>>> cascade="all,delete-orphan">
>>>>>
>>>>> <collection-id column="ID" type="long">
>>>>>
>>>>> <generator class="increment"/>
>>>>>
>>>>> </collection-id>
>>>>>
>>>>> <key/>
>>>>>
>>>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>>>
>>>>> </idbag>
>>>>>
>>>>> This does not look right but any attempt to set something does not
>>>>> work. Is
>>>>> there an @IdBag test suite I can look at?
>>>>>
>>>>> And the exception thrown is:
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: executing flush
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: registering flush begin
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: fetching initial value: select max(ID) from
>>>>> someclass_someotherclass
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>> globally:
>>>>> 0)
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: select max(ID) from someclass_someotherclass
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: preparing statement
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: first free id: 1
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>>>> globally: 1)
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: closing statement
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>> globally:
>>>>> 0)
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?,
>>>>> ?)
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: preparing statement
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>
>>>>> java.sql.SQLException: Column count does not match in statement [insert
>>>>> into
>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>
>>>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>>>
>>>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>>>
>>>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>>>
>>>>> at
>>>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>>>
>>>>> at
>>>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>>>
>>>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>>>
>>>>> at
>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>>>
>>>>> at
>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>>>
>>>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>>>
>>>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>>>
>>>>> at
>>>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>>>
>>>>> at test.TestBag.test(TestBag.java:97)
>>>>>
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>>
>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>>
>>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>>
>>>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>>>
>>>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>>>
>>>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>>>
>>>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>>>
>>>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>>>
>>>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>>>
>>>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>>>
>>>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>>>
>>>>>
>>>>> Also note that the Hibernate doc section you are referring to has
>>>>> changed to
>>>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>>>> It no longer indicates that only one left joined collection is
>>>>> supported -
>>>>> but in practice, I have seen it only work with one collection.
>>>>>
>>>>> Thanks,
>>>>> -mike
>>>>>
>>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>>> news:f35oj1$irq$1@build.eclipse.org...
>>>>>> The syntax is: @IdBag (the source of the annotation is
>>>>>> teneo.hibernate).
>>>>>> But I am not sure if this will solve your problem. The hibernate docs
>>>>>> say
>>>>>> this about it (section 11.3):
>>>>>> Note that, in the current implementation, only one collection role may
>>>>>> be
>>>>>> fetched in a query (everything else would be non-performant). Note
>>>>>> also
>>>>>> that the fetch construct may not be used in queries called using
>>>>>> scroll()
>>>>>> or iterate(). Finally, note that full join fetch and right join fetch
>>>>>> are
>>>>>> not meaningful.
>>>>>>
>>>>>> Afaik the join behavior of an idbag is the same as for a bag. It is
>>>>>> more
>>>>>> the update and insert behavior which is better.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Michael Kanaley wrote:
>>>>>>> What is the syntax of the annotation?
>>>>>>> I have attached an ecore as an example that is working with the
>>>>>>> "refs"
>>>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>>>> instead.
>>>>>>>
>>>>>>> Also, as a side note, the real problem that I am trying to work
>>>>>>> around is
>>>>>>> the following Hibernate exception when left joins on multiple bag
>>>>>>> attributes are done.
>>>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch
>>>>>>> multiple
>>>>>>> bags".
>>>>>>> Will switching to idbags fix this issue?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> -mike
>>>>>> --
>>>>>>
>>>>>> With Regards, Martin Taal
>>>>>>
>>>>>> Springsite/Elver.org
>>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>>> The Netherlands
>>>>>> Tel: +31 (0)84 420 2397
>>>>>> Fax: +31 (0)84 225 9307
>>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>>> Web: www.springsite.com - www.elver.org
>>>> --
>>>>
>>>> With Regards, Martin Taal
>>>>
>>>> Springsite/Elver.org
>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>> The Netherlands
>>>> Tel: +31 (0)84 420 2397
>>>> Fax: +31 (0)84 225 9307
>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>> Web: www.springsite.com - www.elver.org
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #85547 is a reply to message #85472] |
Tue, 05 June 2007 15:57  |
Eclipse User |
|
|
|
Filed bug 191110: Backport fix for using @IdBag annotation from 0.8.0 to
0.7.5
Thanks,
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f3qt4b$nnm$2@build.eclipse.org...
> Hi Mike,
> I solved this in the 0.8.0 release. Please enter a bugzilla to get it also
> back into 0.7.5.
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Hi Martin,
>> Did you file a bug for this issue below. I am interested in this fix
>> (for the 0.7.5 releases) and want to track it so I know which version of
>> Teneo it is supported in.
>>
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:f37kn7$71f$1@build.eclipse.org...
>>> There should be three, two for the joins to both tables (parent and
>>> child) (id and elt) and one for the id of the idbag entry itself (ID).
>>> My guess is that there is a nameclash between the id fields. Although
>>> one is lowercase (id) and the other uppercase (ID) hsqldb does not seem
>>> to make a difference.
>>>
>>> I encountered the same thing in a customer project I am doing right now.
>>> I have added an option to set the name of the idbag id element and this
>>> solved the issue for me.
>>> However, it will take a few weeks before I do a new release with this
>>> solution.
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> The attached image indicates that there are only 2 generated, ID and
>>>> ELT.
>>>> That seems right - why does the Teneo commit fail?
>>>> -mike
>>>>
>>>>
>>>>
>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>> news:f37a8j$38d$2@build.eclipse.org...
>>>>> Hi Mike,
>>>>> The mapping looks fine afaics. How many (and which) columns does the
>>>>> someclass_someotherclass table
>>>>> have?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Michael Kanaley wrote:
>>>>>> Hi Martin,
>>>>>> Sorry it was not clear from my first email but setting the @IdBag
>>>>>> annotation does not work.
>>>>>> Simply add the @IdBag annotation to the example I sent in the
>>>>>> beginning. The
>>>>>> mapping generated is:
>>>>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>>>>> cascade="all,delete-orphan">
>>>>>>
>>>>>> <collection-id column="ID" type="long">
>>>>>>
>>>>>> <generator class="increment"/>
>>>>>>
>>>>>> </collection-id>
>>>>>>
>>>>>> <key/>
>>>>>>
>>>>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>>>>
>>>>>> </idbag>
>>>>>>
>>>>>> This does not look right but any attempt to set something does not
>>>>>> work. Is
>>>>>> there an @IdBag test suite I can look at?
>>>>>>
>>>>>> And the exception thrown is:
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: executing flush
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: registering flush begin
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: fetching initial value: select max(ID) from
>>>>>> someclass_someotherclass
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>>> globally:
>>>>>> 0)
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: select max(ID) from someclass_someotherclass
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: preparing statement
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: first free id: 1
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>>>>> globally: 1)
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: closing statement
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>>> globally:
>>>>>> 0)
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?,
>>>>>> ?, ?)
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: preparing statement
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>>
>>>>>> java.sql.SQLException: Column count does not match in statement
>>>>>> [insert into
>>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>>
>>>>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>>>>
>>>>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>>>>
>>>>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>>>>
>>>>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>>>>
>>>>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>>>>
>>>>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>>>>
>>>>>> at test.TestBag.test(TestBag.java:97)
>>>>>>
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>>>
>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>>>
>>>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>>>
>>>>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>>>>
>>>>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>>>>
>>>>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>>>>
>>>>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>>>>
>>>>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>>>>
>>>>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>>>>
>>>>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>>>>
>>>>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>>>>
>>>>>>
>>>>>> Also note that the Hibernate doc section you are referring to has
>>>>>> changed to
>>>>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>>>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>>>>> It no longer indicates that only one left joined collection is
>>>>>> supported -
>>>>>> but in practice, I have seen it only work with one collection.
>>>>>>
>>>>>> Thanks,
>>>>>> -mike
>>>>>>
>>>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>>>> news:f35oj1$irq$1@build.eclipse.org...
>>>>>>> The syntax is: @IdBag (the source of the annotation is
>>>>>>> teneo.hibernate).
>>>>>>> But I am not sure if this will solve your problem. The hibernate
>>>>>>> docs say
>>>>>>> this about it (section 11.3):
>>>>>>> Note that, in the current implementation, only one collection role
>>>>>>> may be
>>>>>>> fetched in a query (everything else would be non-performant). Note
>>>>>>> also
>>>>>>> that the fetch construct may not be used in queries called using
>>>>>>> scroll()
>>>>>>> or iterate(). Finally, note that full join fetch and right join
>>>>>>> fetch are
>>>>>>> not meaningful.
>>>>>>>
>>>>>>> Afaik the join behavior of an idbag is the same as for a bag. It is
>>>>>>> more
>>>>>>> the update and insert behavior which is better.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Michael Kanaley wrote:
>>>>>>>> What is the syntax of the annotation?
>>>>>>>> I have attached an ecore as an example that is working with the
>>>>>>>> "refs"
>>>>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>>>>> instead.
>>>>>>>>
>>>>>>>> Also, as a side note, the real problem that I am trying to work
>>>>>>>> around is
>>>>>>>> the following Hibernate exception when left joins on multiple bag
>>>>>>>> attributes are done.
>>>>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch
>>>>>>>> multiple
>>>>>>>> bags".
>>>>>>>> Will switching to idbags fix this issue?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> -mike
>>>>>>> --
>>>>>>>
>>>>>>> With Regards, Martin Taal
>>>>>>>
>>>>>>> Springsite/Elver.org
>>>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>>>> The Netherlands
>>>>>>> Tel: +31 (0)84 420 2397
>>>>>>> Fax: +31 (0)84 225 9307
>>>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>>>> Web: www.springsite.com - www.elver.org
>>>>> --
>>>>>
>>>>> With Regards, Martin Taal
>>>>>
>>>>> Springsite/Elver.org
>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>> The Netherlands
>>>>> Tel: +31 (0)84 420 2397
>>>>> Fax: +31 (0)84 225 9307
>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>> Web: www.springsite.com - www.elver.org
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Tel: +31 (0)84 420 2397
>>> Fax: +31 (0)84 225 9307
>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>> Web: www.springsite.com - www.elver.org
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606787 is a reply to message #84800] |
Fri, 25 May 2007 00:27  |
Eclipse User |
|
|
|
The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
But I am not sure if this will solve your problem. The hibernate docs say this about it (section 11.3):
Note that, in the current implementation, only one collection role may be fetched in a query
(everything else would be non-performant). Note also that the fetch construct may not be used in
queries called using scroll() or iterate(). Finally, note that full join fetch and right join fetch
are not meaningful.
Afaik the join behavior of an idbag is the same as for a bag. It is more the update and insert
behavior which is better.
gr. Martin
Michael Kanaley wrote:
> What is the syntax of the annotation?
> I have attached an ecore as an example that is working with the "refs"
> EAttribute of SomeClass using bags. I would like it to use IdBags instead.
>
> Also, as a side note, the real problem that I am trying to work around is
> the following Hibernate exception when left joins on multiple bag attributes
> are done.
> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
> bags".
> Will switching to idbags fix this issue?
>
> Thanks,
> -mike
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606791 is a reply to message #84858] |
Fri, 25 May 2007 10:26  |
Eclipse User |
|
|
|
Hi Martin,
Sorry it was not clear from my first email but setting the @IdBag
annotation does not work.
Simply add the @IdBag annotation to the example I sent in the beginning. The
mapping generated is:
<idbag name="refs" table="someclass_someotherclass" lazy="true"
cascade="all,delete-orphan">
<collection-id column="ID" type="long">
<generator class="increment"/>
</collection-id>
<key/>
<many-to-many entity-name="SomeOtherClass" unique="false"/>
</idbag>
This does not look right but any attempt to set something does not work. Is
there an @IdBag test suite I can look at?
And the exception thrown is:
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: executing flush
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: registering flush begin
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: Inserting collection: [SomeClass.refs#1]
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: fetching initial value: select max(ID) from someclass_someotherclass
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
0)
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: select max(ID) from someclass_someotherclass
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: preparing statement
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: first free id: 1
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: about to close PreparedStatement (open PreparedStatements: 1,
globally: 1)
May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: closing statement
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
0)
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
FINE: preparing statement
May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
FINE: could not insert collection: [SomeClass.refs#1] [insert into
someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
java.sql.SQLException: Column count does not match in statement [insert into
someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at
org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
at
org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
at
org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
at
org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
at
org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
at test.TestBag.test(TestBag.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
Also note that the Hibernate doc section you are referring to has changed to
14.3 for Hibernate 3.2.2 and it's content is slightly different.
http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
It no longer indicates that only one left joined collection is supported -
but in practice, I have seen it only work with one collection.
Thanks,
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f35oj1$irq$1@build.eclipse.org...
> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
> But I am not sure if this will solve your problem. The hibernate docs say
> this about it (section 11.3):
> Note that, in the current implementation, only one collection role may be
> fetched in a query (everything else would be non-performant). Note also
> that the fetch construct may not be used in queries called using scroll()
> or iterate(). Finally, note that full join fetch and right join fetch are
> not meaningful.
>
> Afaik the join behavior of an idbag is the same as for a bag. It is more
> the update and insert behavior which is better.
>
> gr. Martin
>
> Michael Kanaley wrote:
>> What is the syntax of the annotation?
>> I have attached an ecore as an example that is working with the "refs"
>> EAttribute of SomeClass using bags. I would like it to use IdBags
>> instead.
>>
>> Also, as a side note, the real problem that I am trying to work around is
>> the following Hibernate exception when left joins on multiple bag
>> attributes are done.
>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>> bags".
>> Will switching to idbags fix this issue?
>>
>> Thanks,
>> -mike
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606802 is a reply to message #84919] |
Fri, 25 May 2007 14:34  |
Eclipse User |
|
|
|
Hi Mike,
The mapping looks fine afaics. How many (and which) columns does the someclass_someotherclass table
have?
gr. Martin
Michael Kanaley wrote:
> Hi Martin,
> Sorry it was not clear from my first email but setting the @IdBag
> annotation does not work.
> Simply add the @IdBag annotation to the example I sent in the beginning. The
> mapping generated is:
> <idbag name="refs" table="someclass_someotherclass" lazy="true"
> cascade="all,delete-orphan">
>
> <collection-id column="ID" type="long">
>
> <generator class="increment"/>
>
> </collection-id>
>
> <key/>
>
> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>
> </idbag>
>
> This does not look right but any attempt to set something does not work. Is
> there an @IdBag test suite I can look at?
>
> And the exception thrown is:
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: executing flush
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: registering flush begin
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: Inserting collection: [SomeClass.refs#1]
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: fetching initial value: select max(ID) from someclass_someotherclass
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
> 0)
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: select max(ID) from someclass_someotherclass
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: preparing statement
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: first free id: 1
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: about to close PreparedStatement (open PreparedStatements: 1,
> globally: 1)
>
> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: closing statement
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: about to open PreparedStatement (open PreparedStatements: 0, globally:
> 0)
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>
> FINE: preparing statement
>
> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>
> FINE: could not insert collection: [SomeClass.refs#1] [insert into
> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>
> java.sql.SQLException: Column count does not match in statement [insert into
> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>
> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>
> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>
> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>
> at
> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>
> at
> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>
> at
> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>
> at
> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>
> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>
> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>
> at
> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>
> at
> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>
> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>
> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>
> at
> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>
> at test.TestBag.test(TestBag.java:97)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>
> at java.lang.reflect.Method.invoke(Unknown Source)
>
> at junit.framework.TestCase.runTest(TestCase.java:154)
>
> at junit.framework.TestCase.runBare(TestCase.java:127)
>
> at junit.framework.TestResult$1.protect(TestResult.java:106)
>
> at junit.framework.TestResult.runProtected(TestResult.java:124)
>
> at junit.framework.TestResult.run(TestResult.java:109)
>
> at junit.framework.TestCase.run(TestCase.java:118)
>
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>
> at junit.framework.TestSuite.run(TestSuite.java:203)
>
> at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>
>
> Also note that the Hibernate doc section you are referring to has changed to
> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
> It no longer indicates that only one left joined collection is supported -
> but in practice, I have seen it only work with one collection.
>
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f35oj1$irq$1@build.eclipse.org...
>> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
>> But I am not sure if this will solve your problem. The hibernate docs say
>> this about it (section 11.3):
>> Note that, in the current implementation, only one collection role may be
>> fetched in a query (everything else would be non-performant). Note also
>> that the fetch construct may not be used in queries called using scroll()
>> or iterate(). Finally, note that full join fetch and right join fetch are
>> not meaningful.
>>
>> Afaik the join behavior of an idbag is the same as for a bag. It is more
>> the update and insert behavior which is better.
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> What is the syntax of the annotation?
>>> I have attached an ecore as an example that is working with the "refs"
>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>> instead.
>>>
>>> Also, as a side note, the real problem that I am trying to work around is
>>> the following Hibernate exception when left joins on multiple bag
>>> attributes are done.
>>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>>> bags".
>>> Will switching to idbags fix this issue?
>>>
>>> Thanks,
>>> -mike
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606803 is a reply to message #85089] |
Fri, 25 May 2007 16:48  |
Eclipse User |
|
|
|
The attached image indicates that there are only 2 generated, ID and ELT.
That seems right - why does the Teneo commit fail?
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f37a8j$38d$2@build.eclipse.org...
> Hi Mike,
> The mapping looks fine afaics. How many (and which) columns does the
> someclass_someotherclass table
> have?
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Hi Martin,
>> Sorry it was not clear from my first email but setting the @IdBag
>> annotation does not work.
>> Simply add the @IdBag annotation to the example I sent in the beginning.
>> The
>> mapping generated is:
>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>> cascade="all,delete-orphan">
>>
>> <collection-id column="ID" type="long">
>>
>> <generator class="increment"/>
>>
>> </collection-id>
>>
>> <key/>
>>
>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>
>> </idbag>
>>
>> This does not look right but any attempt to set something does not work.
>> Is
>> there an @IdBag test suite I can look at?
>>
>> And the exception thrown is:
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: executing flush
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: registering flush begin
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: Inserting collection: [SomeClass.refs#1]
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: fetching initial value: select max(ID) from
>> someclass_someotherclass
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>> globally:
>> 0)
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: select max(ID) from someclass_someotherclass
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: preparing statement
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: first free id: 1
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>> globally: 1)
>>
>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: closing statement
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>> globally:
>> 0)
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>
>> FINE: preparing statement
>>
>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>
>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>
>> java.sql.SQLException: Column count does not match in statement [insert
>> into
>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>
>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>
>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>
>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>
>> at
>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>
>> at
>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>
>> at
>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>
>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>
>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>
>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>
>> at
>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>
>> at
>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>
>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>
>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>
>> at
>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>
>> at test.TestBag.test(TestBag.java:97)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>
>> at java.lang.reflect.Method.invoke(Unknown Source)
>>
>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>
>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>
>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>
>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>
>> at junit.framework.TestResult.run(TestResult.java:109)
>>
>> at junit.framework.TestCase.run(TestCase.java:118)
>>
>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>
>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>
>>
>> Also note that the Hibernate doc section you are referring to has changed
>> to
>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>> It no longer indicates that only one left joined collection is
>> supported -
>> but in practice, I have seen it only work with one collection.
>>
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:f35oj1$irq$1@build.eclipse.org...
>>> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
>>> But I am not sure if this will solve your problem. The hibernate docs
>>> say
>>> this about it (section 11.3):
>>> Note that, in the current implementation, only one collection role may
>>> be
>>> fetched in a query (everything else would be non-performant). Note also
>>> that the fetch construct may not be used in queries called using
>>> scroll()
>>> or iterate(). Finally, note that full join fetch and right join fetch
>>> are
>>> not meaningful.
>>>
>>> Afaik the join behavior of an idbag is the same as for a bag. It is more
>>> the update and insert behavior which is better.
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> What is the syntax of the annotation?
>>>> I have attached an ecore as an example that is working with the "refs"
>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>> instead.
>>>>
>>>> Also, as a side note, the real problem that I am trying to work around
>>>> is
>>>> the following Hibernate exception when left joins on multiple bag
>>>> attributes are done.
>>>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>>>> bags".
>>>> Will switching to idbags fix this issue?
>>>>
>>>> Thanks,
>>>> -mike
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Tel: +31 (0)84 420 2397
>>> Fax: +31 (0)84 225 9307
>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>> Web: www.springsite.com - www.elver.org
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606804 is a reply to message #85104] |
Fri, 25 May 2007 17:33  |
Eclipse User |
|
|
|
There should be three, two for the joins to both tables (parent and child) (id and elt) and one for
the id of the idbag entry itself (ID). My guess is that there is a nameclash between the id fields.
Although one is lowercase (id) and the other uppercase (ID) hsqldb does not seem to make a difference.
I encountered the same thing in a customer project I am doing right now. I have added an option to
set the name of the idbag id element and this solved the issue for me.
However, it will take a few weeks before I do a new release with this solution.
gr. Martin
Michael Kanaley wrote:
> The attached image indicates that there are only 2 generated, ID and ELT.
> That seems right - why does the Teneo commit fail?
> -mike
>
>
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f37a8j$38d$2@build.eclipse.org...
>> Hi Mike,
>> The mapping looks fine afaics. How many (and which) columns does the
>> someclass_someotherclass table
>> have?
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> Hi Martin,
>>> Sorry it was not clear from my first email but setting the @IdBag
>>> annotation does not work.
>>> Simply add the @IdBag annotation to the example I sent in the beginning.
>>> The
>>> mapping generated is:
>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>> cascade="all,delete-orphan">
>>>
>>> <collection-id column="ID" type="long">
>>>
>>> <generator class="increment"/>
>>>
>>> </collection-id>
>>>
>>> <key/>
>>>
>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>
>>> </idbag>
>>>
>>> This does not look right but any attempt to set something does not work.
>>> Is
>>> there an @IdBag test suite I can look at?
>>>
>>> And the exception thrown is:
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: executing flush
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: registering flush begin
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: fetching initial value: select max(ID) from
>>> someclass_someotherclass
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>> globally:
>>> 0)
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: select max(ID) from someclass_someotherclass
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: preparing statement
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: first free id: 1
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>> globally: 1)
>>>
>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: closing statement
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>> globally:
>>> 0)
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?, ?)
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>
>>> FINE: preparing statement
>>>
>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>
>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>
>>> java.sql.SQLException: Column count does not match in statement [insert
>>> into
>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>
>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>
>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>
>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>
>>> at
>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>
>>> at
>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>
>>> at
>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>
>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>
>>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>
>>> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>
>>> at
>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>
>>> at
>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>
>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>
>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>
>>> at
>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>
>>> at test.TestBag.test(TestBag.java:97)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>
>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>
>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>
>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>
>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>
>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>
>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>
>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>
>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>
>>>
>>> Also note that the Hibernate doc section you are referring to has changed
>>> to
>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>> It no longer indicates that only one left joined collection is
>>> supported -
>>> but in practice, I have seen it only work with one collection.
>>>
>>> Thanks,
>>> -mike
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:f35oj1$irq$1@build.eclipse.org...
>>>> The syntax is: @IdBag (the source of the annotation is teneo.hibernate).
>>>> But I am not sure if this will solve your problem. The hibernate docs
>>>> say
>>>> this about it (section 11.3):
>>>> Note that, in the current implementation, only one collection role may
>>>> be
>>>> fetched in a query (everything else would be non-performant). Note also
>>>> that the fetch construct may not be used in queries called using
>>>> scroll()
>>>> or iterate(). Finally, note that full join fetch and right join fetch
>>>> are
>>>> not meaningful.
>>>>
>>>> Afaik the join behavior of an idbag is the same as for a bag. It is more
>>>> the update and insert behavior which is better.
>>>>
>>>> gr. Martin
>>>>
>>>> Michael Kanaley wrote:
>>>>> What is the syntax of the annotation?
>>>>> I have attached an ecore as an example that is working with the "refs"
>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>> instead.
>>>>>
>>>>> Also, as a side note, the real problem that I am trying to work around
>>>>> is
>>>>> the following Hibernate exception when left joins on multiple bag
>>>>> attributes are done.
>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch multiple
>>>>> bags".
>>>>> Will switching to idbags fix this issue?
>>>>>
>>>>> Thanks,
>>>>> -mike
>>>> --
>>>>
>>>> With Regards, Martin Taal
>>>>
>>>> Springsite/Elver.org
>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>> The Netherlands
>>>> Tel: +31 (0)84 420 2397
>>>> Fax: +31 (0)84 225 9307
>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>> Web: www.springsite.com - www.elver.org
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606848 is a reply to message #85121] |
Fri, 01 June 2007 07:46  |
Eclipse User |
|
|
|
Hi Martin,
Did you file a bug for this issue below. I am interested in this fix (for
the 0.7.5 releases) and want to track it so I know which version of Teneo it
is supported in.
Thanks,
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f37kn7$71f$1@build.eclipse.org...
> There should be three, two for the joins to both tables (parent and child)
> (id and elt) and one for the id of the idbag entry itself (ID). My guess
> is that there is a nameclash between the id fields. Although one is
> lowercase (id) and the other uppercase (ID) hsqldb does not seem to make a
> difference.
>
> I encountered the same thing in a customer project I am doing right now. I
> have added an option to set the name of the idbag id element and this
> solved the issue for me.
> However, it will take a few weeks before I do a new release with this
> solution.
>
> gr. Martin
>
> Michael Kanaley wrote:
>> The attached image indicates that there are only 2 generated, ID and ELT.
>> That seems right - why does the Teneo commit fail?
>> -mike
>>
>>
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:f37a8j$38d$2@build.eclipse.org...
>>> Hi Mike,
>>> The mapping looks fine afaics. How many (and which) columns does the
>>> someclass_someotherclass table
>>> have?
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> Hi Martin,
>>>> Sorry it was not clear from my first email but setting the @IdBag
>>>> annotation does not work.
>>>> Simply add the @IdBag annotation to the example I sent in the
>>>> beginning. The
>>>> mapping generated is:
>>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>>> cascade="all,delete-orphan">
>>>>
>>>> <collection-id column="ID" type="long">
>>>>
>>>> <generator class="increment"/>
>>>>
>>>> </collection-id>
>>>>
>>>> <key/>
>>>>
>>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>>
>>>> </idbag>
>>>>
>>>> This does not look right but any attempt to set something does not
>>>> work. Is
>>>> there an @IdBag test suite I can look at?
>>>>
>>>> And the exception thrown is:
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: executing flush
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: registering flush begin
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: fetching initial value: select max(ID) from
>>>> someclass_someotherclass
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>> globally:
>>>> 0)
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: select max(ID) from someclass_someotherclass
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: preparing statement
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: first free id: 1
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>>> globally: 1)
>>>>
>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: closing statement
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>> globally:
>>>> 0)
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?,
>>>> ?)
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>
>>>> FINE: preparing statement
>>>>
>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>
>>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>
>>>> java.sql.SQLException: Column count does not match in statement [insert
>>>> into
>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>
>>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>>
>>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>>
>>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>>
>>>> at
>>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>>
>>>> at
>>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>>
>>>> at
>>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>>
>>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>>
>>>> at
>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>>
>>>> at
>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>>
>>>> at
>>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>>
>>>> at
>>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>>
>>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>>
>>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>>
>>>> at
>>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>>
>>>> at test.TestBag.test(TestBag.java:97)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>
>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>
>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>
>>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>>
>>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>>
>>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>>
>>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>>
>>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>>
>>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>>
>>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>>
>>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>>
>>>>
>>>> Also note that the Hibernate doc section you are referring to has
>>>> changed to
>>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>>> It no longer indicates that only one left joined collection is
>>>> supported -
>>>> but in practice, I have seen it only work with one collection.
>>>>
>>>> Thanks,
>>>> -mike
>>>>
>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>> news:f35oj1$irq$1@build.eclipse.org...
>>>>> The syntax is: @IdBag (the source of the annotation is
>>>>> teneo.hibernate).
>>>>> But I am not sure if this will solve your problem. The hibernate docs
>>>>> say
>>>>> this about it (section 11.3):
>>>>> Note that, in the current implementation, only one collection role may
>>>>> be
>>>>> fetched in a query (everything else would be non-performant). Note
>>>>> also
>>>>> that the fetch construct may not be used in queries called using
>>>>> scroll()
>>>>> or iterate(). Finally, note that full join fetch and right join fetch
>>>>> are
>>>>> not meaningful.
>>>>>
>>>>> Afaik the join behavior of an idbag is the same as for a bag. It is
>>>>> more
>>>>> the update and insert behavior which is better.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Michael Kanaley wrote:
>>>>>> What is the syntax of the annotation?
>>>>>> I have attached an ecore as an example that is working with the
>>>>>> "refs"
>>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>>> instead.
>>>>>>
>>>>>> Also, as a side note, the real problem that I am trying to work
>>>>>> around is
>>>>>> the following Hibernate exception when left joins on multiple bag
>>>>>> attributes are done.
>>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch
>>>>>> multiple
>>>>>> bags".
>>>>>> Will switching to idbags fix this issue?
>>>>>>
>>>>>> Thanks,
>>>>>> -mike
>>>>> --
>>>>>
>>>>> With Regards, Martin Taal
>>>>>
>>>>> Springsite/Elver.org
>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>> The Netherlands
>>>>> Tel: +31 (0)84 420 2397
>>>>> Fax: +31 (0)84 225 9307
>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>> Web: www.springsite.com - www.elver.org
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Tel: +31 (0)84 420 2397
>>> Fax: +31 (0)84 225 9307
>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>> Web: www.springsite.com - www.elver.org
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606851 is a reply to message #85442] |
Sat, 02 June 2007 00:53  |
Eclipse User |
|
|
|
Hi Mike,
I solved this in the 0.8.0 release. Please enter a bugzilla to get it also back into 0.7.5.
gr. Martin
Michael Kanaley wrote:
> Hi Martin,
> Did you file a bug for this issue below. I am interested in this fix (for
> the 0.7.5 releases) and want to track it so I know which version of Teneo it
> is supported in.
>
> Thanks,
> -mike
>
> "Martin Taal" <mtaal@elver.org> wrote in message
> news:f37kn7$71f$1@build.eclipse.org...
>> There should be three, two for the joins to both tables (parent and child)
>> (id and elt) and one for the id of the idbag entry itself (ID). My guess
>> is that there is a nameclash between the id fields. Although one is
>> lowercase (id) and the other uppercase (ID) hsqldb does not seem to make a
>> difference.
>>
>> I encountered the same thing in a customer project I am doing right now. I
>> have added an option to set the name of the idbag id element and this
>> solved the issue for me.
>> However, it will take a few weeks before I do a new release with this
>> solution.
>>
>> gr. Martin
>>
>> Michael Kanaley wrote:
>>> The attached image indicates that there are only 2 generated, ID and ELT.
>>> That seems right - why does the Teneo commit fail?
>>> -mike
>>>
>>>
>>>
>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>> news:f37a8j$38d$2@build.eclipse.org...
>>>> Hi Mike,
>>>> The mapping looks fine afaics. How many (and which) columns does the
>>>> someclass_someotherclass table
>>>> have?
>>>>
>>>> gr. Martin
>>>>
>>>> Michael Kanaley wrote:
>>>>> Hi Martin,
>>>>> Sorry it was not clear from my first email but setting the @IdBag
>>>>> annotation does not work.
>>>>> Simply add the @IdBag annotation to the example I sent in the
>>>>> beginning. The
>>>>> mapping generated is:
>>>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>>>> cascade="all,delete-orphan">
>>>>>
>>>>> <collection-id column="ID" type="long">
>>>>>
>>>>> <generator class="increment"/>
>>>>>
>>>>> </collection-id>
>>>>>
>>>>> <key/>
>>>>>
>>>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>>>
>>>>> </idbag>
>>>>>
>>>>> This does not look right but any attempt to set something does not
>>>>> work. Is
>>>>> there an @IdBag test suite I can look at?
>>>>>
>>>>> And the exception thrown is:
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: executing flush
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: registering flush begin
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: fetching initial value: select max(ID) from
>>>>> someclass_someotherclass
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>> globally:
>>>>> 0)
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: select max(ID) from someclass_someotherclass
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: preparing statement
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: first free id: 1
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>>>> globally: 1)
>>>>>
>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: closing statement
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>> globally:
>>>>> 0)
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?, ?,
>>>>> ?)
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog trace
>>>>>
>>>>> FINE: preparing statement
>>>>>
>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog debug
>>>>>
>>>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>
>>>>> java.sql.SQLException: Column count does not match in statement [insert
>>>>> into
>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>
>>>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>>>
>>>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>>>
>>>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>>>
>>>>> at
>>>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>>>
>>>>> at
>>>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>>>
>>>>> at
>>>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>>>
>>>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>>>
>>>>> at
>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>>>
>>>>> at
>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>>>
>>>>> at
>>>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>>>
>>>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>>>
>>>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>>>
>>>>> at
>>>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>>>
>>>>> at test.TestBag.test(TestBag.java:97)
>>>>>
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>
>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>>
>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>>
>>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>>
>>>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>>>
>>>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>>>
>>>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>>>
>>>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>>>
>>>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>>>
>>>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>>>
>>>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>>>
>>>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>>
>>>>> at
>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>>>
>>>>>
>>>>> Also note that the Hibernate doc section you are referring to has
>>>>> changed to
>>>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>>>> It no longer indicates that only one left joined collection is
>>>>> supported -
>>>>> but in practice, I have seen it only work with one collection.
>>>>>
>>>>> Thanks,
>>>>> -mike
>>>>>
>>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>>> news:f35oj1$irq$1@build.eclipse.org...
>>>>>> The syntax is: @IdBag (the source of the annotation is
>>>>>> teneo.hibernate).
>>>>>> But I am not sure if this will solve your problem. The hibernate docs
>>>>>> say
>>>>>> this about it (section 11.3):
>>>>>> Note that, in the current implementation, only one collection role may
>>>>>> be
>>>>>> fetched in a query (everything else would be non-performant). Note
>>>>>> also
>>>>>> that the fetch construct may not be used in queries called using
>>>>>> scroll()
>>>>>> or iterate(). Finally, note that full join fetch and right join fetch
>>>>>> are
>>>>>> not meaningful.
>>>>>>
>>>>>> Afaik the join behavior of an idbag is the same as for a bag. It is
>>>>>> more
>>>>>> the update and insert behavior which is better.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Michael Kanaley wrote:
>>>>>>> What is the syntax of the annotation?
>>>>>>> I have attached an ecore as an example that is working with the
>>>>>>> "refs"
>>>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>>>> instead.
>>>>>>>
>>>>>>> Also, as a side note, the real problem that I am trying to work
>>>>>>> around is
>>>>>>> the following Hibernate exception when left joins on multiple bag
>>>>>>> attributes are done.
>>>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch
>>>>>>> multiple
>>>>>>> bags".
>>>>>>> Will switching to idbags fix this issue?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> -mike
>>>>>> --
>>>>>>
>>>>>> With Regards, Martin Taal
>>>>>>
>>>>>> Springsite/Elver.org
>>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>>> The Netherlands
>>>>>> Tel: +31 (0)84 420 2397
>>>>>> Fax: +31 (0)84 225 9307
>>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>>> Web: www.springsite.com - www.elver.org
>>>> --
>>>>
>>>> With Regards, Martin Taal
>>>>
>>>> Springsite/Elver.org
>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>> The Netherlands
>>>> Tel: +31 (0)84 420 2397
>>>> Fax: +31 (0)84 225 9307
>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>> Web: www.springsite.com - www.elver.org
>>>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Can someone provide an example of using the @IdBag annotation in Elver... [message #606859 is a reply to message #85472] |
Tue, 05 June 2007 15:57  |
Eclipse User |
|
|
|
Filed bug 191110: Backport fix for using @IdBag annotation from 0.8.0 to
0.7.5
Thanks,
-mike
"Martin Taal" <mtaal@elver.org> wrote in message
news:f3qt4b$nnm$2@build.eclipse.org...
> Hi Mike,
> I solved this in the 0.8.0 release. Please enter a bugzilla to get it also
> back into 0.7.5.
>
> gr. Martin
>
> Michael Kanaley wrote:
>> Hi Martin,
>> Did you file a bug for this issue below. I am interested in this fix
>> (for the 0.7.5 releases) and want to track it so I know which version of
>> Teneo it is supported in.
>>
>> Thanks,
>> -mike
>>
>> "Martin Taal" <mtaal@elver.org> wrote in message
>> news:f37kn7$71f$1@build.eclipse.org...
>>> There should be three, two for the joins to both tables (parent and
>>> child) (id and elt) and one for the id of the idbag entry itself (ID).
>>> My guess is that there is a nameclash between the id fields. Although
>>> one is lowercase (id) and the other uppercase (ID) hsqldb does not seem
>>> to make a difference.
>>>
>>> I encountered the same thing in a customer project I am doing right now.
>>> I have added an option to set the name of the idbag id element and this
>>> solved the issue for me.
>>> However, it will take a few weeks before I do a new release with this
>>> solution.
>>>
>>> gr. Martin
>>>
>>> Michael Kanaley wrote:
>>>> The attached image indicates that there are only 2 generated, ID and
>>>> ELT.
>>>> That seems right - why does the Teneo commit fail?
>>>> -mike
>>>>
>>>>
>>>>
>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>> news:f37a8j$38d$2@build.eclipse.org...
>>>>> Hi Mike,
>>>>> The mapping looks fine afaics. How many (and which) columns does the
>>>>> someclass_someotherclass table
>>>>> have?
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Michael Kanaley wrote:
>>>>>> Hi Martin,
>>>>>> Sorry it was not clear from my first email but setting the @IdBag
>>>>>> annotation does not work.
>>>>>> Simply add the @IdBag annotation to the example I sent in the
>>>>>> beginning. The
>>>>>> mapping generated is:
>>>>>> <idbag name="refs" table="someclass_someotherclass" lazy="true"
>>>>>> cascade="all,delete-orphan">
>>>>>>
>>>>>> <collection-id column="ID" type="long">
>>>>>>
>>>>>> <generator class="increment"/>
>>>>>>
>>>>>> </collection-id>
>>>>>>
>>>>>> <key/>
>>>>>>
>>>>>> <many-to-many entity-name="SomeOtherClass" unique="false"/>
>>>>>>
>>>>>> </idbag>
>>>>>>
>>>>>> This does not look right but any attempt to set something does not
>>>>>> work. Is
>>>>>> there an @IdBag test suite I can look at?
>>>>>>
>>>>>> And the exception thrown is:
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: executing flush
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: registering flush begin
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: Inserting collection: [SomeClass.refs#1]
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: fetching initial value: select max(ID) from
>>>>>> someclass_someotherclass
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>>> globally:
>>>>>> 0)
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: select max(ID) from someclass_someotherclass
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: preparing statement
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: first free id: 1
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: about to close PreparedStatement (open PreparedStatements: 1,
>>>>>> globally: 1)
>>>>>>
>>>>>> May 25, 2007 10:13:17 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: closing statement
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: about to open PreparedStatement (open PreparedStatements: 0,
>>>>>> globally:
>>>>>> 0)
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: insert into someclass_someotherclass (id, ID, elt) values (?,
>>>>>> ?, ?)
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> trace
>>>>>>
>>>>>> FINE: preparing statement
>>>>>>
>>>>>> May 25, 2007 10:13:18 AM org.apache.commons.logging.impl.SLF4JLog
>>>>>> debug
>>>>>>
>>>>>> FINE: could not insert collection: [SomeClass.refs#1] [insert into
>>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>>
>>>>>> java.sql.SQLException: Column count does not match in statement
>>>>>> [insert into
>>>>>> someclass_someotherclass (id, ID, elt) values (?, ?, ?)]
>>>>>>
>>>>>> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
>>>>>>
>>>>>> at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
>>>>>>
>>>>>> at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(Abst ractBatcher.java:497)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:94)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:218)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
>>>>>>
>>>>>> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:24 8)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:232)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:143)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
>>>>>>
>>>>>> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
>>>>>>
>>>>>> at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
>>>>>>
>>>>>> at
>>>>>> org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
>>>>>>
>>>>>> at test.TestBag.test(TestBag.java:97)
>>>>>>
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>
>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>>>
>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>>>
>>>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>>>
>>>>>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>>>>>
>>>>>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>>>>>
>>>>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>>>>
>>>>>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>>>>>
>>>>>> at junit.framework.TestResult.run(TestResult.java:109)
>>>>>>
>>>>>> at junit.framework.TestCase.run(TestCase.java:118)
>>>>>>
>>>>>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>>>>>
>>>>>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:128)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)
>>>>>>
>>>>>>
>>>>>> Also note that the Hibernate doc section you are referring to has
>>>>>> changed to
>>>>>> 14.3 for Hibernate 3.2.2 and it's content is slightly different.
>>>>>> http://www.hibernate.org/hib_docs/v3/reference/en/html_singl e/#queryhql-joins
>>>>>> It no longer indicates that only one left joined collection is
>>>>>> supported -
>>>>>> but in practice, I have seen it only work with one collection.
>>>>>>
>>>>>> Thanks,
>>>>>> -mike
>>>>>>
>>>>>> "Martin Taal" <mtaal@elver.org> wrote in message
>>>>>> news:f35oj1$irq$1@build.eclipse.org...
>>>>>>> The syntax is: @IdBag (the source of the annotation is
>>>>>>> teneo.hibernate).
>>>>>>> But I am not sure if this will solve your problem. The hibernate
>>>>>>> docs say
>>>>>>> this about it (section 11.3):
>>>>>>> Note that, in the current implementation, only one collection role
>>>>>>> may be
>>>>>>> fetched in a query (everything else would be non-performant). Note
>>>>>>> also
>>>>>>> that the fetch construct may not be used in queries called using
>>>>>>> scroll()
>>>>>>> or iterate(). Finally, note that full join fetch and right join
>>>>>>> fetch are
>>>>>>> not meaningful.
>>>>>>>
>>>>>>> Afaik the join behavior of an idbag is the same as for a bag. It is
>>>>>>> more
>>>>>>> the update and insert behavior which is better.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Michael Kanaley wrote:
>>>>>>>> What is the syntax of the annotation?
>>>>>>>> I have attached an ecore as an example that is working with the
>>>>>>>> "refs"
>>>>>>>> EAttribute of SomeClass using bags. I would like it to use IdBags
>>>>>>>> instead.
>>>>>>>>
>>>>>>>> Also, as a side note, the real problem that I am trying to work
>>>>>>>> around is
>>>>>>>> the following Hibernate exception when left joins on multiple bag
>>>>>>>> attributes are done.
>>>>>>>> "org.hibernate.HibernateException: cannot simultaneously fetch
>>>>>>>> multiple
>>>>>>>> bags".
>>>>>>>> Will switching to idbags fix this issue?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> -mike
>>>>>>> --
>>>>>>>
>>>>>>> With Regards, Martin Taal
>>>>>>>
>>>>>>> Springsite/Elver.org
>>>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>>>> The Netherlands
>>>>>>> Tel: +31 (0)84 420 2397
>>>>>>> Fax: +31 (0)84 225 9307
>>>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>>>> Web: www.springsite.com - www.elver.org
>>>>> --
>>>>>
>>>>> With Regards, Martin Taal
>>>>>
>>>>> Springsite/Elver.org
>>>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>>>> The Netherlands
>>>>> Tel: +31 (0)84 420 2397
>>>>> Fax: +31 (0)84 225 9307
>>>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>>>> Web: www.springsite.com - www.elver.org
>>>>
>>>
>>> --
>>>
>>> With Regards, Martin Taal
>>>
>>> Springsite/Elver.org
>>> Office: Hardwareweg 4, 3821 BV Amersfoort
>>> Postal: Nassaulaan 7, 3941 EC Doorn
>>> The Netherlands
>>> Tel: +31 (0)84 420 2397
>>> Fax: +31 (0)84 225 9307
>>> Mail: mtaal@springsite.com - mtaal@elver.org
>>> Web: www.springsite.com - www.elver.org
>>
>>
>
>
> --
>
> With Regards, Martin Taal
>
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Sat May 03 05:20:31 EDT 2025
Powered by FUDForum. Page generated in 0.05880 seconds
|