-->
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.  [ 7 posts ] 
Author Message
 Post subject: Issues w/ <composite-element> mapping
PostPosted: Tue Feb 01, 2005 8:03 am 
Newbie

Joined: Thu Oct 09, 2003 7:15 pm
Posts: 11
Location: London, UK
Hi All,
I was wondering if anyone could explain this hibernate behaviour to me. I’ve read the docs et all but still don’t grasp why this is happening.
I have a LoanType class which has a composite element with a nested <many-to-one> elements of type LoanTypeTranslations, themselves on a many-to-many association with Languages objects.
Now everytime I issue a simple retrieve objects of type LoanTypeTranslation hibernate issues the following SQL commands:

-A select for loan type objecs, as expected,
-A select for languages, as expected,
-An update on loan types,

And then a sequence of two very unexpected commands,
-A delete from loanTypeTranslations,
-And an insert into LoanTypeTranslations

it seems hibernate destroys everything to build it up again.



Hibernate version:

2.1.8

Mapping documents:

LoanType.hbm.xml:

<hibernate-mapping package="org.lds.mocs.loan">
<class name="LoanType" table="LoanType" mutable="true">

<meta attribute="implement-equals" inherit="false">true</meta>
<meta attribute="extra-import">org.lds.util.SystemDefaults</meta>
<meta attribute="extra-import">java.util.Iterator</meta>
<meta attribute="extra-import">org.lds.mocs.common.Language</meta>

<id name="id"
type="integer"
column="loanTypeId">
<generator class="sequence">
<param name="sequence">LoanType_pkseq</param>
</generator>
</id>

<timestamp name="lastUpdated"
column="lastupdated"
access="property"
unsaved-value="null">
</timestamp>

<property name="defaultDescription"
type="string"
column="DefaultDescription"
length="120"
not-null="true"
unique="true">
<meta attribute="use-in-equals">true</meta>
</property>

<property name="defaultLanguage"
type="integer"
column="defaultLanguageId"
not-null="true">
<meta attribute="use-in-equals">true</meta>
</property>

<set name="loanTypeTranslationSet"
lazy="true"
table="LoanTypeTranslation"
cascade="all"
order-by="languageID asc">
<key column="loanTypeId"/>
<composite-element class="org.lds.mocs.loan.LoanTypeTranslation">
<many-to-one name="language"
column="languageid"
class="org.lds.mocs.common.Language"
unique="false"
not-null="true"
cascade="all"
update="true"
insert="true">
</many-to-one>

<property name="translationTxt"
type="string"
column="translationTxt"
length="120"
not-null="true"/>
<property name="lastUpdated"
type="date"
column="lastupdated"
not-null="true"/>
<property name="updatedBy"
type="string"
column="UPDATEDBY"
length="40"
not-null="true"/>
</composite-element>
</set>

<property name="stdLoanLength"
type="java.lang.Integer"
column="stdLoanLength"
not-null="true">
</property>

<set name="mediaLoanTypes"
table="MediaType_LoanType"
lazy="true"
inverse="true">
<meta attribute="field-description">Loan type for this media type</meta>
<meta attribute="scope-set">protected</meta>
<key column="loanTypeId"/>
<many-to-many class="org.lds.mocs.inventory.MediaType" column="mediaTypeId"/>
</set>

<property name="sortValue"
type="integer"
column="sortValue"
not-null="false">
</property>

<property name="updatedById"
type="string"
column="updatedById"
length="80"
not-null="true">
</property>

</class>



Code between sessionFactory.openSession() and session.close():

public LoanType getLoanTypeById(int loanTypeId)
{
logger.info("LoanTypeDaoImpl --> Entered getLoanTypeById(int)");
LoanType lt = null;
List typeList = getHibernateTemplate().find("from LoanType lt left join fetch lt.loanTypeTranslationSet where lt.id=?", new Integer(loanTypeId));
if (!typeList.isEmpty())
{
return (LoanType) typeList.get(0);
}
return null;
}


Full stack trace of any exception that occurs:



Name and version of the database you are using:

Oracle 9i

The generated SQL (show_sql=true):

11:35:37,828 INFO [LoanTypeDaoImpl] LoanTypeDaoImpl --> Entered getLoanTypeById
(int)
11:35:37,828 INFO [STDOUT] Hibernate: select loantype0_.loanTypeId as loanTypeI
d, loantype0_.lastupdated as lastupda2_, loantype0_.DefaultDescription as Defaul
tD3_, loantype0_.defaultLanguageId as defaultL4_, loantype0_.stdLoanLength as st
dLoanL5_, loantype0_.sortValue as sortValue, loantype0_.updatedById as updatedB7
_, loantypetr1_.languageid as languageid__, loantypetr1_.translationTxt as trans
lat3___, loantypetr1_.lastupdated as lastupda4___, loantypetr1_.UPDATEDBY as UPD
ATEDBY__, loantypetr1_.loanTypeId as loanTypeId__ from LoanType loantype0_, Loan
TypeTranslation loantypetr1_ where loantype0_.loanTypeId=loantypetr1_.loanTypeId
(+) and ((loantype0_.loanTypeId=? )) order by loantypetr1_.languageID asc

11:35:37,843 INFO [STDOUT] Hibernate: select language0_.languageid as languagei
d0_, language0_.lastupdated as lastupda2_0_, language0_.languagename as language
3_0_, language0_.updatebyid as updatebyid0_ from LANGUAGE language0_ where langu
age0_.languageid=?

11:35:37,859 INFO [STDOUT] Hibernate: update LoanType set lastupdated=?, Defaul
tDescription=?, defaultLanguageId=?, stdLoanLength=?, sortValue=?, updatedById=?
where loanTypeId=? and lastupdated=?

11:35:37,859 INFO [STDOUT] Hibernate: delete from LoanTypeTranslation where loa
nTypeId=? and languageid=? and translationTxt=? and lastupdated=? and UPDATEDBY=
?
11:35:37,875 INFO [STDOUT] Hibernate: insert into LoanTypeTranslation (loanType
Id, languageid, translationTxt, lastupdated, UPDATEDBY) values (?, ?, ?, ?, ?)

11:35:37,875 INFO [LoanTypeDaoImpl] LoanTypeDaoImpl --> Exited getLoanTypeById(
int)



Debug level Hibernate log excerpt:


2005-02-01 11:35:37,828 DEBUG [org.lds.mocs.webservice.server.SystemAxisServerEndPoint] getLoanTypeTranslation: Preparing to validate Loan type -> 4
2005-02-01 11:35:37,828 INFO [org.lds.mocs.dao.hibernate.LoanTypeDaoImpl] LoanTypeDaoImpl --> Entered getLoanTypeById(int)
2005-02-01 11:35:37,828 DEBUG [org.springframework.orm.hibernate.SessionFactoryUtils] Opening Hibernate session
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] opened session
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] find: from LoanType lt left join fetch lt.loanTypeTranslationSet where lt.id=?
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.engine.QueryParameters] parameters: [4]
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.engine.QueryParameters] named parameters: {}
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.hql.QueryTranslator] compiling query
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] flushing session
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushing entities and processing referenced collections
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] Processing unreferenced collections
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] Scheduling collection removes/(re)creates/updates
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.SessionImpl] Dont need to execute flush
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.hql.QueryTranslator] HQL: from org.lds.mocs.loan.LoanType lt left join fetch lt.loanTypeTranslationSet where lt.id=?
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.hql.QueryTranslator] SQL: select loantype0_.loanTypeId as loanTypeId, loantype0_.lastupdated as lastupda2_, loantype0_.DefaultDescription as DefaultD3_, loantype0_.defaultLanguageId as defaultL4_, loantype0_.stdLoanLength as stdLoanL5_, loantype0_.sortValue as sortValue, loantype0_.updatedById as updatedB7_, loantypetr1_.languageid as languageid__, loantypetr1_.translationTxt as translat3___, loantypetr1_.lastupdated as lastupda4___, loantypetr1_.UPDATEDBY as UPDATEDBY__, loantypetr1_.loanTypeId as loanTypeId__ from LoanType loantype0_, LoanTypeTranslation loantypetr1_ where loantype0_.loanTypeId=loantypetr1_.loanTypeId(+) and ((loantype0_.loanTypeId=? )) order by loantypetr1_.languageID asc
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.BatcherImpl] about to open: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.SQL] select loantype0_.loanTypeId as loanTypeId, loantype0_.lastupdated as lastupda2_, loantype0_.DefaultDescription as DefaultD3_, loantype0_.defaultLanguageId as defaultL4_, loantype0_.stdLoanLength as stdLoanL5_, loantype0_.sortValue as sortValue, loantype0_.updatedById as updatedB7_, loantypetr1_.languageid as languageid__, loantypetr1_.translationTxt as translat3___, loantypetr1_.lastupdated as lastupda4___, loantypetr1_.UPDATEDBY as UPDATEDBY__, loantypetr1_.loanTypeId as loanTypeId__ from LoanType loantype0_, LoanTypeTranslation loantypetr1_ where loantype0_.loanTypeId=loantypetr1_.loanTypeId(+) and ((loantype0_.loanTypeId=? )) order by loantypetr1_.languageID asc
2005-02-01 11:35:37,828 INFO [STDOUT] Hibernate: select loantype0_.loanTypeId as loanTypeId, loantype0_.lastupdated as lastupda2_, loantype0_.DefaultDescription as DefaultD3_, loantype0_.defaultLanguageId as defaultL4_, loantype0_.stdLoanLength as stdLoanL5_, loantype0_.sortValue as sortValue, loantype0_.updatedById as updatedB7_, loantypetr1_.languageid as languageid__, loantypetr1_.translationTxt as translat3___, loantypetr1_.lastupdated as lastupda4___, loantypetr1_.UPDATEDBY as UPDATEDBY__, loantypetr1_.loanTypeId as loanTypeId__ from LoanType loantype0_, LoanTypeTranslation loantypetr1_ where loantype0_.loanTypeId=loantypetr1_.loanTypeId(+) and ((loantype0_.loanTypeId=? )) order by loantypetr1_.languageID asc
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.type.IntegerType] binding '4' to parameter: 1
2005-02-01 11:35:37,828 DEBUG [net.sf.hibernate.loader.Loader] processing result set
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] returning '4' as column: loanTypeId
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] result row: 4
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] Initializing object from ResultSet: 4
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] Hydrating entity: org.lds.mocs.loan.LoanType#4
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.TimestampType] returning '01 February 2005 11:20:47' as column: lastupda2_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.StringType] returning 'another1' as column: DefaultD3_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] returning '1' as column: defaultL4_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] returning '7' as column: stdLoanL5_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] returning '0' as column: sortValue
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.StringType] returning 'SysAdmin' as column: updatedB7_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] Version: 2005-02-01 11:20:47.0
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] returning '4' as column: loanTypeId__
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] found row of collection: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] new collection: instantiating
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] returning '37' as column: languageid__
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.StringType] returning 'Ni hao' as column: translat3___
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.DateType] returning '25 January 2005' as column: lastupda4___
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.StringType] returning 'SysAdmin' as column: UPDATEDBY__
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] loading [org.lds.mocs.common.Language#37]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] attempting to resolve [org.lds.mocs.common.Language#37]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] object not resolved in any cache [org.lds.mocs.common.Language#37]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.persister.EntityPersister] Materializing entity: [org.lds.mocs.common.Language#37]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.BatcherImpl] about to open: 1 open PreparedStatements, 1 open ResultSets
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.SQL] select language0_.languageid as languageid0_, language0_.lastupdated as lastupda2_0_, language0_.languagename as language3_0_, language0_.updatebyid as updatebyid0_ from LANGUAGE language0_ where language0_.languageid=?
2005-02-01 11:35:37,843 INFO [STDOUT] Hibernate: select language0_.languageid as languageid0_, language0_.lastupdated as lastupda2_0_, language0_.languagename as language3_0_, language0_.updatebyid as updatebyid0_ from LANGUAGE language0_ where language0_.languageid=?
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.IntegerType] binding '37' to parameter: 1
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] processing result set
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] result row: 37
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] Initializing object from ResultSet: 37
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] Hydrating entity: org.lds.mocs.common.Language#37
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.TimestampType] returning '02 June 1997 12:22:47' as column: lastupda2_0_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.StringType] returning 'Chinese' as column: language3_0_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.type.StringType] returning 'CORC' as column: updatebyid0_
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] Version: 1997-06-02 12:22:47.0
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] done processing result set (1 rows)
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 1 open PreparedStatements, 1 open ResultSets
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] total objects hydrated: 1
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] resolving associations for [org.lds.mocs.common.Language#37]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] done materializing entity [org.lds.mocs.common.Language#37]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] done processing result set (1 rows)
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.loader.Loader] total objects hydrated: 1
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] resolving associations for [org.lds.mocs.loan.LoanType#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] returning loading collection:[org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] creating collection wrapper:[org.lds.mocs.loan.LoanType.mediaLoanTypes#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] done materializing entity [org.lds.mocs.loan.LoanType#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] 1 collections were found in result set
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] collection fully initialized: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] 1 collections initialized
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] initializing non-lazy collections
2005-02-01 11:35:37,843 DEBUG [org.springframework.orm.hibernate.HibernateTemplate] Eagerly flushing Hibernate session
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] flushing session
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] Collection dirty: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushing entities and processing referenced collections
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.impl.SessionImpl] Updating entity: [org.lds.mocs.loan.LoanType#4]
2005-02-01 11:35:37,843 DEBUG [net.sf.hibernate.engine.Versioning] Incrementing: 2005-02-01 11:20:47.0 to 2005-02-01 11:35:37.843
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] Collection found: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4], was: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] Collection found: [org.lds.mocs.loan.LoanType.mediaLoanTypes#4], was: [org.lds.mocs.loan.LoanType.mediaLoanTypes#4]
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] Processing unreferenced collections
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] Scheduling collection removes/(re)creates/updates
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 insertions, 1 updates, 0 deletions to 2 objects
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] Flushed: 0 (re)creations, 1 updates, 0 removals to 2 collections
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.Printer] listing entities:
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.Printer] org.lds.mocs.loan.LoanType{stdLoanLength=7, mediaLoanTypes=uninitialized, sortValue=0, updatedById=SysAdmin, defaultLanguage=1, lastUpdated=01 February 2005 11:20:47, loanTypeTranslationSet=[LoanTypeTranslation{updatedBy=SysAdmin, lastUpdated=25 January 2005, translationTxt=Ni hao, language=Language#37}], defaultDescription=another1, id=4}
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.Printer] org.lds.mocs.common.Language{languageName=Chinese, updateById=CORC, lastUpdated=02 June 1997 12:22:47, id=37}
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.SessionImpl] executing flush
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.persister.EntityPersister] Updating entity: [org.lds.mocs.loan.LoanType#4]
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.persister.EntityPersister] Existing version: 2005-02-01 11:20:47.0 -> New version: 2005-02-01 11:35:37.843
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] about to open: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.SQL] update LoanType set lastupdated=?, DefaultDescription=?, defaultLanguageId=?, stdLoanLength=?, sortValue=?, updatedById=? where loanTypeId=? and lastupdated=?
2005-02-01 11:35:37,859 INFO [STDOUT] Hibernate: update LoanType set lastupdated=?, DefaultDescription=?, defaultLanguageId=?, stdLoanLength=?, sortValue=?, updatedById=? where loanTypeId=? and lastupdated=?
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.persister.EntityPersister] Dehydrating entity: [org.lds.mocs.loan.LoanType#4]
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.TimestampType] binding '01 February 2005 11:35:37' to parameter: 1
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.StringType] binding 'another1' to parameter: 2
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.IntegerType] binding '1' to parameter: 3
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.IntegerType] binding '7' to parameter: 4
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.IntegerType] binding '0' to parameter: 5
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.StringType] binding 'SysAdmin' to parameter: 6
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.IntegerType] binding '4' to parameter: 7
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.TimestampType] binding '01 February 2005 11:20:47' to parameter: 8
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.collection.BasicCollectionPersister] Deleting rows of collection: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] about to open: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.SQL] delete from LoanTypeTranslation where loanTypeId=? and languageid=? and translationTxt=? and lastupdated=? and UPDATEDBY=?
2005-02-01 11:35:37,859 INFO [STDOUT] Hibernate: delete from LoanTypeTranslation where loanTypeId=? and languageid=? and translationTxt=? and lastupdated=? and UPDATEDBY=?
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.IntegerType] binding '4' to parameter: 1
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.IntegerType] binding '37' to parameter: 2
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.StringType] binding 'Ni hao' to parameter: 3
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.DateType] binding '25 January 2005' to parameter: 4
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.type.StringType] binding 'SysAdmin' to parameter: 5
2005-02-01 11:35:37,859 DEBUG [net.sf.hibernate.impl.BatcherImpl] Adding to batch
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.collection.BasicCollectionPersister] done deleting collection rows: 1 deleted
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.collection.BasicCollectionPersister] Updating rows of collection: org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.collection.BasicCollectionPersister] done updating rows: 0 updated
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.collection.BasicCollectionPersister] Inserting rows of collection: [org.lds.mocs.loan.LoanType.loanTypeTranslationSet#4]
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] Executing batch size: 1
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] success of batch update unknown: 0
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] about to open: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.SQL] insert into LoanTypeTranslation (loanTypeId, languageid, translationTxt, lastupdated, UPDATEDBY) values (?, ?, ?, ?, ?)
2005-02-01 11:35:37,875 INFO [STDOUT] Hibernate: insert into LoanTypeTranslation (loanTypeId, languageid, translationTxt, lastupdated, UPDATEDBY) values (?, ?, ?, ?, ?)
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] preparing statement
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.type.IntegerType] binding '4' to parameter: 1
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.type.IntegerType] binding '37' to parameter: 2
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.type.StringType] binding 'Ni hao' to parameter: 3
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.type.DateType] binding '25 January 2005' to parameter: 4
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.type.StringType] binding 'SysAdmin' to parameter: 5
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] Adding to batch
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.collection.BasicCollectionPersister] done inserting rows: 1 inserted
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] Executing batch size: 1
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] success of batch update unknown: 0
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] done closing: 0 open PreparedStatements, 0 open ResultSets
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.BatcherImpl] closing statement
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.SessionImpl] post flush
2005-02-01 11:35:37,875 DEBUG [org.springframework.orm.hibernate.SessionFactoryUtils] Closing Hibernate session
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.SessionImpl] closing session
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.SessionImpl] disconnecting session
2005-02-01 11:35:37,875 DEBUG [net.sf.hibernate.impl.SessionImpl] transaction completion
2005-02-01 11:35:37,875 INFO [org.lds.mocs.dao.hibernate.LoanTypeDaoImpl] LoanTypeDaoImpl --> Exited getLoanTypeById(int)


Top
 Profile  
 
 Post subject: Timestamp issues instead
PostPosted: Mon Feb 07, 2005 6:32 am 
Newbie

Joined: Thu Oct 09, 2003 7:15 pm
Posts: 11
Location: London, UK
Well it seems this was being caused by the timestamp property rather than being an <composite-element> issue. When we replaced it with 'version' everything worked fine.
Now I've got a few questions:

-Is this timestamp behavior documented anywhere?
-Is it such a daft question, am I missing something here?
-Is it behaving the way it should? I find it hard to believe that is the best thing to do, destroying to rebuild the same thing next.

Cheers
jorge


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 6:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Looks like you have a bug. Use your debugger., and the HIbernate log.


Top
 Profile  
 
 Post subject: Timestamp
PostPosted: Tue Feb 08, 2005 7:43 am 
Newbie

Joined: Thu Oct 09, 2003 7:15 pm
Posts: 11
Location: London, UK
Thanks for your reply.

We've done that, stripped our code down to the bare minimum, and all things indicated a bug/odd behavior from hibernate's timestamp side. Unfortunately, we already wasted too much time on this issue and now that <version> is working as we wanted it and all tests passed successfully, we won't be pursuing this any further.

Cheers
jorge


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 8:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I don't believe it has anything to do with the timestamp.

I think it is much more likely you forgot to implement equals()/hashCode() correctly for the coomposite elements you are putting the the Set.

Which means that your current correct behavior is just masking the underlying problem somehow.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 12, 2005 5:56 pm 
Newbie

Joined: Thu May 12, 2005 5:54 pm
Posts: 16
I also faced a similar problem.

Setting inverse=true on the set and implementing hashcode/equals
for the class in the set solved the problem.


Top
 Profile  
 
 Post subject: inverse="true" was only a workaround solution
PostPosted: Mon May 16, 2005 5:53 pm 
Newbie

Joined: Thu May 12, 2005 5:54 pm
Posts: 16
I finally figured out what my problem was?

On my Parent class i had code like this:
Set children;
public Set getChildren() {
return Collections.unmodifiableCollection(this.children);
}

As such this collection was different from the collection hibernate would set As such it would think that collection is modified and go ahead and delete the old collection and re-inser the new one.

Now when I added inverse="true" I only told hibernate ingnore this end for db synchronization. As such deletes/inserts stopped. And note that mine was a uniderctional many to many on a join table. So inverse=true was inapproproate.

The correct solution that i have tested and works is:

private Set getChildren() {
return this.chlidren;
}

private void setChildren(Set children) {
this.children = children;
}

public Iterator children() {
return this.children.iterator();
}

//add remove methods for chlildren

Above solution makes me use hibernate as well as ensure usage of an Encapsulated Collection. http://martinfowler.com/bliki/Encapsula ... ction.html


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