-->
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.  [ 3 posts ] 
Author Message
 Post subject: TransientObjectException während Criteria-Aufruf
PostPosted: Tue Dec 09, 2008 11:35 am 
Newbie

Joined: Mon May 19, 2008 9:27 am
Posts: 8
Hallo,

ich hab ein Problem und finde im Netz einfach keine Antworten (vielleicht suche ich auch falsch).

Ich möchte per QueryByExample die Criteria-API nutzen um ein Hibernate-gemapptes Objekt oder Objekte zu suchen. Leider kriege ich nun immer die folgende Exception:
Quote:
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: .Company
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:87)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1707)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1678)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1563)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)





Hibernate-Version : 3.2.6ga

Mapping:
Quote:
<hibernate-mapping default-lazy="false">
<class name="AccountBalance" table="aTable"
persister="MasterDataLoggingEntityPersister">
<composite-id name="accountBalanceId" class="AccountBalanceId"
access="field">
<key-property name="closingDatePeriodId" type="ClosingDatePeriodID"
access="field">
<column name="ABR_MON_JAHR" length="10" />
</key-property>
<key-property name="companyId" type="CompanyID" access="field">
<column name="GES" length="20" not-null="true" />
</key-property>
</composite-id>

<many-to-one lazy="no-proxy" name="closingDatePeriod"
class="ClosingDatePeriod" insert="false" update="false" access="field"
foreign-key="K003K004">
<column name="ABR_MON_JAHR" length="10" />
</many-to-one>
<many-to-one lazy="no-proxy" name="company" class="Company"
insert="false" update="false" access="field" foreign-key="key">
<column name="GES" length="20" />
</many-to-one>

</class>
</hibernate-mapping>


Code
Quote:
Example example = Example.create(anAccountBalance);
Session commonSession = this.getCommonSession();
Criteria theCriteria = commonSession.createCriteria(anAccountBalance.getClass());
Criteria add = null;
SimpleExpression simpleExpression = (SimpleExpression) iterator.next();
add = theCriteria.add(simpleExpression);

List<T> list = null;
commonSession.flush();
list = add.list();


Thanxs in advance
Christian


Top
 Profile  
 
 Post subject: Re: TransientObjectException Criteria-Aufruf - Gelöst
PostPosted: Thu Dec 11, 2008 9:35 am 
Newbie

Joined: Mon May 19, 2008 9:27 am
Posts: 8
Hallo zusammen,

ich hab das Problem gelöst und zwar durch einfaches Lesen der Doku.

Schade, dass die Fehlermeldung an dieser Stelle mehr oder weniger nicht zu gebrauchen ist.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2009 7:23 am 
Newbie

Joined: Fri Feb 06, 2009 2:17 pm
Posts: 1
Hallo,
was war die Lösung zu diesem Problem? Ich habe dieselbe Situation wie beschreibt, genau das geschieht wenn Criteria.list() ist geruft.


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