-->
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.  [ 6 posts ] 
Author Message
 Post subject: 1.2 cr2- Transient object Exception
PostPosted: Sun Apr 22, 2007 12:14 pm 
Newbie

Joined: Tue Jan 17, 2006 5:00 am
Posts: 16
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:1.2 cr2

Just tried out this version but had to switch back to b3 again. I'm getting massive Transient object exception on most of my test cases after a switch to cr2 - so my question is was there a bug in b3 or is there one in cr2.

When I say massive I mean almost every test case I have written now fails with a transient object exception - which all worked fine in b3....

Any ideas why?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 22, 2007 2:44 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Possibly the connection release mode change. Post the code and exception info.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 4:29 am 
Newbie

Joined: Tue Jan 17, 2006 5:00 am
Posts: 16
How does this work :

* Does each session have it's own connection
* Where/how do I configure the release mode

In most my test cases I have two session's running simultaneously, one for the main work and one for generating sequences (have to do this myself as SQL server dosen't support oracle style sequences) for for primary keys, which shoulden't hold a lock while my main work is executing - my hunch tells me that might be the problem... therefore the question on whether each session keeps it's own connection...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 4:56 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
We could help you much faster if you showed the code. The connection release mode may not even be related to your problem, it was just a guess. If you set property hibernate.connection.release_mode to on_close you will get the legacy behavior.

Yes, each session has its own connection.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 11:36 am 
Newbie

Joined: Tue Jan 17, 2006 5:00 am
Posts: 16
I'm a little bit closer now to the problem at hand - and no, the release mode diden't solve the problem. I'm just not sure how to explain because if i'm to post the code it would be a lot of code because there are a lot of objects related to each other.

One this I can see after debugging some was that the object causing the problem seems to be a object that was only related to Nhibernate through an many-to-one association (Vinnerbud - see xml furtner down). I instanciate it in the property if not present just to be sure not to have a null reference. It's done like this :

public virtual Nettbud Vinnerbud
{
get
{
if ((_vinnerbud == null || _vinnerbudid != _vinnerbud.Nettbudid))
{
if (_vinnerbudid == null)
_vinnerbud = daoFactory.CreateNettbud().CreateNew(); // fake, just to have one - not to be persisted
else
_vinnerbud = daoFactory.CreateNettbud().Fetch(_vinnerbudid ?? 0);
}

return _vinnerbud;
}
set
{
if (_vinnerbud != value)
{
if (value == null) _vinnerbudid = null; else _vinnerbudid = value.Nettbudid;
_vinnerbud = value;
}
}
}

I believe that it's the object created in the code

(_vinnerbud = daoFactory.CreateNettbud().CreateNew())

that Nhibernate argues is transient, but this worked fine in beta3.

Another issue that I came across in cr2 as well, was that even though I have defined in the XML that insert=false and update=false, Nhibernate seems to still try to save the object - hence the transient error, and when modifying my code not to return an "Vinnerbud" instance in the property code Nhibernate would still try to update the related object but fail because the field "Vinnerbudid" was in the SQL twice. That's actually an issue I have struggled with before and why I have set insert="false" and update="false" in the first place - not that I quite understood why this actually had to be so...

So basically my best guess is that cr2, is trying to "help" me persist my association "Vinnerbud" even though I have told it not to bother...

I hope this helps to trace down the issue.





<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Blomqvist"
assembly ="Blomqvist"
>

<class
name = "Nettobjekt"
table= "[dbo].[Nettobjekt]"
batch-size="20"
dynamic-update="true"
dynamic-insert="true"
>

<id
name="NettobjektID"
column="NettobjektID"
type="System.Int32" >
<generator class="Blomqvist.HibernateGenerator, Blomqvist" />
</id>

<version
name="HBVersion"
column="HBVersion"
type="System.Int32"
unsaved-value="null"
/>

<property name="NettauksjonsID" column="NettauksjonsID" type="System.Int32" ></property>
<property name="Objektid" column="Objektid" type="System.Int32" ></property>
<property name="Start" column="Start" type="System.DateTime" ></property>
<property name="Slutt" column="Slutt" type="System.DateTime" ></property>
<property name="SluttInformert" ></property>
<property name="Visninger" ></property>
<property name="Vinnerbudid" ></property>

<many-to-one
name = "Nettauksjon"
class = "Nettauksjon"
cascade = "none"
fetch="select"
insert = "false"
update = "false" >
<column name="NettauksjonsID" />
</many-to-one>

<many-to-one
name = "Objekt"
class = "Objekt_mini"
cascade = "none"
insert = "false"
update = "false" >
<column name="Objektid" />
</many-to-one>

<!--
-->
<many-to-one
name = "Vinnerbud"
class = "Nettbud"
cascade = "none"
fetch="select"
insert = "false"
update = "false"
not-found="ignore"
outer-join="true"
column="Vinnerbudid"
>
</many-to-one>

<bag
name="Nettautobud"
cascade="all-delete-orphan"
order-by="Belop desc, Tidspunkt desc"
lazy="true"
inverse="true" >
<key>
<column name= "NettobjektID" />
</key>
<one-to-many class="Nettautobud" />
</bag>

<bag
name="Nettbud"
order-by="Nettbudid desc"
cascade="all-delete-orphan"
lazy="true"
inverse="true" >
<key>
<column name= "NettobjektID" />
</key>
<one-to-many class="Nettbud" />
</bag>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:59 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Can you please create a bug report in JIRA and attach a simplified test case to it?


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