-->
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.  [ 4 posts ] 
Author Message
 Post subject: one-to-many with inverse="false" : many issues
PostPosted: Wed May 12, 2004 2:18 pm 
Newbie

Joined: Thu Mar 25, 2004 1:10 pm
Posts: 3
Hello everybody,

I've came across some issues while trying to use a one-to-many relationship with inverse="false".

Let's have a look at my POJOs.

First the POJO corresponding to the parent in the one-to-many relationship :

public class Service extends BaseObject
{
private Set contacts = new HashSet();

/**
* Adds a contact to a service
* @param contact Le contact


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 12, 2004 2:20 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Show your mapping files.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 5:15 am 
Newbie

Joined: Thu Mar 25, 2004 1:10 pm
Posts: 3
Here are my mapping files :

SERVICE

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="org.cg83.xpa.model.Service"
table="SERVICE"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="IDSERVICE"
type="java.lang.Long"
length="10"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>

<set
name="contacts"
lazy="true"
inverse="false"
cascade="save-update"
sort="unsorted"
>

<key
column="IDSERVICE"
/>

<one-to-many
class="org.cg83.xpa.model.Contact"
/>
</set>

</class>

</hibernate-mapping>


CONTACT

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="org.cg83.xpa.model.Contact"
table="CONTACT"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="IDCONTACT"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>

<property
name="civilite"
type="java.lang.String"
update="true"
insert="true"
column="CVLCONTACT"
length="5"
/>

<property
name="commentaire"
type="java.lang.String"
update="true"
insert="true"
column="COMCONTACT"
length="500"
/>

<property
name="fax"
type="java.lang.String"
update="true"
insert="true"
column="FAXCONTACT"
length="20"
/>

<many-to-one
name="fonction"
class="org.cg83.xpa.model.Fonction"
cascade="none"
outer-join="true"
update="true"
insert="true"
column="CODFONCTION"
/>

<property
name="mail"
type="java.lang.String"
update="true"
insert="true"
column="EMAILCONTACT"
length="100"
/>

</class>

</hibernate-mapping>


Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 2:17 pm 
Newbie

Joined: Thu Mar 25, 2004 1:10 pm
Posts: 3
I have some news.
In my unit test class, i have several test methods. When i comment out all mthese methods except the one that give me some trouble, everything works as expected. Here is the debug log obtained from Hibernate :

[code]
[junit] testGetService getContacts start...
[junit] [xpa] DEBUG [main] SessionImpl.initializeCollection(3251) | initializing collection [org.cg83.xpa.model.Service.contacts#20]
[junit] [xpa] DEBUG [main] SessionImpl.initializeCollection(3252) | checking second-level cache
[junit] [xpa] DEBUG [main] SessionImpl.initializeCollection(3258) | collection not cached
[junit] [xpa] DEBUG [main] BatcherImpl.logOpenPreparedStatement(196) | about to open: 0 open PreparedStatements, 0 open ResultSets
[junit] [xpa] DEBUG [main] BatcherImpl.getPreparedStatement(237) | select contacts0_.IDCONTACT as IDCONTACT__, contacts0_.IDSERVICE as IDSERVICE__, contacts0_.IDCONTACT as IDCONTACT1_, contacts0_.CVLCONTACT as CVLCONTACT1_, contacts0_.COMCONTACT as COMCONTACT1_, contacts0_.DATDERMOD as DATDERMOD1_, contacts0_.FAXCONTACT as FAXCONTACT1_, contacts0_.CODFONCTION as CODFONCT6_1_, contacts0_.EMAILCONTACT as EMAILCON7_1_, contacts0_.NOMCONTACT as NOMCONTACT1_, contacts0_.PRENOMCONTACT as PRENOMCO9_1_, contacts0_.TELCONTACT as TELCONTACT1_, contacts0_.USERDERMOD as USERDERMOD1_, fonction1_.CODFONCTION as CODFONCT1_0_, fonction1_.LIBFONCTION as LIBFONCT2_0_ from CONTACT contacts0_, FONCTION fonction1_ where contacts0_.IDSERVICE=? and contacts0_.CODFONCTION=fonction1_.CODFONCTION(+)
[junit] [xpa] DEBUG [main] BatcherImpl.getPreparedStatement(241) | preparing statement
[junit] [xpa] DEBUG [main] NullableType.nullSafeSet(46) | binding '20' to parameter: 1
[junit] [xpa] DEBUG [main] Loader.handleEmptyCollections(327) | result set contains (possibly empty) collection: [org.cg83.xpa.model.Service.contacts#20]
[junit] [xpa] DEBUG [main] SessionImpl.getLoadingCollection(3009) | uninitialized collection: initializing
[junit] [xpa] DEBUG [main] Loader.doQuery(197) | processing result set
[junit] [xpa] DEBUG [main] NullableType.nullSafeGet(68) | returning '10' as column: CODFONCT1_0_
[junit] [xpa] DEBUG [main] NullableType.nullSafeGet(68) | returning '60' as column: IDCONTACT1_
[junit] [xpa] DEBUG [main] Loader.getRow(405) | result row: 10, 60
[junit] [xpa] DEBUG [main] Loader.loadFromResultSet(536) | Initializing object from ResultSet: 10
[junit] [xpa] DEBUG [main] Loader.hydrate(605) | Hydrating entity: org.cg83.xpa.model.Fonction#10
[junit] [xpa] DEBUG [main] NullableType.nullSafeGet(68) | returning 'Responsable Administratif' as column: LIBFONCT2_0_
[junit] [xpa] DEBUG [main] Loader.loadFromResultSet(536) | Initializing object from ResultSet: 60
[junit] [xpa] DEBUG [main] Loader.hydrate(605) | Hydrating entity: org.cg83.xpa.model.Contact#60
[junit] [xpa] DEBUG [main] NullableType.nullSafeGet(68) | returning 'M.' as column: CVLCONTACT1_
[junit] [xpa] DEBUG [main] NullableType.nullSafeGet(68) | returning 'A contacter si besoin de renseignements
[junit] administratifs. Utiliser de pr


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.