These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Does idbag support "native" generator for collecti
PostPosted: Tue Jan 17, 2006 9:50 am 
Newbie

Joined: Mon Dec 12, 2005 10:45 am
Posts: 12
Hibernate version:
Hibernate 3.1

Mapping documents:
Code:
   
      <idbag name="affectedLRUs" table="DEVIATIONS_PARTS">
         <collection-id type="long" column="ITEM_ID">
            <generator class="native" />
         </collection-id>
         <key column="DEV_ID" />
         <composite-element class="AffectedLRU">
            <parent name="deviation" />
            <many-to-one name="affectedPart" class="Part" column="AFFECTED_PART_ID" not-null="true" lazy="false" />
            <many-to-one name="correctivePart" class="Part" column="CORRECTIVE_PART_ID" not-null="false" lazy="false" />
         </composite-element>
      </idbag>


Code between sessionFactory.openSession() and session.close():
N/A

Full stack trace of any exception that occurs:
N/A

Name and version of the database you are using:
Oracle 9i AND MySQL 4.x.x

The generated SQL (show_sql=true):
N/A

Debug level Hibernate log excerpt:
N/A

I had the impression that no other generator than "sequence" was supported idbag's collection-id (The samples in the reference doc only show "sequence" generator, same for HIA).

Because we use (local) MySQL database for developement and testing I tryed and test "native" as the generator...and it works !

Can an authorized persons here can confirm me that "native" IS indeed supported as the generator for idbag's <collection-id> element under Hibernate 3.1 ?

TIA.

Pascal Jacob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 12:40 pm 
Newbie

Joined: Mon Dec 12, 2005 10:45 am
Posts: 12
---Continued---

"native" generator for idbag's collection-id is ok only with Oracle (9i).

When used with MySQL, Hibernate will produce an exception when persisting new instances of the association entity:

Code:
Hibernate:
    insert
    into
        DEVIATIONS_PARTS
        (DEV_ID, ITEM_ID, AFFECTED_PART_ID, CORRECTIVE_PART_ID)
    values
        (?, ?, ?, ?)


Code:
Caused by: java.sql.BatchUpdateException: Statement parameter 2 not set.
   at com.mysql.jdbc.ServerPreparedStatement.executeBatch(ServerPreparedStatement.java:647)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
   ... 25 more



In searching for another generator that would work with both Oracle and MySQL, I have switched from "native" to "increment" for (unit)testing while we are developping the product as I understand that "increment" is not safe when the database is shared by multiple clients.

So the current mater of fact is:
Fact 1) idbag only work (safely) with "sequence" generator.
Fact 2) "sequence" générator is not available under MySQL.
Conclusion) idbag can not be used when the target database is MySQL.

I'm correct ?
Is there an alternative to idbag that I can use to map a ternary association where one of the three foreign key can be null ?

Please help [ I will rate ;-) ]

Pascal Jacob


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.