-->
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.  [ 1 post ] 
Author Message
 Post subject: Uninitialized Proxy with one-to-one Association
PostPosted: Tue Jan 31, 2006 11:36 pm 
Newbie

Joined: Tue Jan 24, 2006 10:02 pm
Posts: 12
Hi,

I have a problem with a one-to-zero/one association with lazy loading.
Job (1) --- (0..1) MachineSetup

Code:
Machinesetup ms = new Machinesetup(DateTime.Now, DateTime.Now);
Job jo = (Job)session.Load(typeof(Job), 6);
ms.Job = jo;
session.Save(ms);

throws me an exception, whereas a non-proxied Job object works fine.

Any Ideas?

Hibernate version:
NHibernate 1.02

Mapping documents:

Class: MachineSetup
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MIS.Domain.Machinesetup,MIS.Domain" table="machinesetup" lazy="true">

<id name="JobId" column="Job_ID" type="Int32" unsaved-value="0">
<generator class="foreign">
<param name="property">Job</param>
</generator>
</id>
<one-to-one name="Job" class="MIS.Domain.Job,MIS.Domain" constrained="true" />
<bag name="Breaks" table="MachineSetup_has_Break" lazy="true" >
<key column="Job_ID" />
<many-to-many class="MIS.Domain.Break,MIS.Domain" column="Break_ID" />
</bag>
<bag name="Persons" table="MachineSetup_has_Person" lazy="true" >
<key column="Job_ID" />
<many-to-many class="MIS.Domain.Person,MIS.Domain" column="Person_ID" />
</bag>
<bag name="SetupSettings" inverse="true" lazy="true" >
<key column="Job_ID" />
<one-to-many class="MIS.Domain.Setupsetting,MIS.Domain" />
</bag>
<property column="StartTime" type="DateTime" name="StartTime" not-null="true" />
<property column="EndTime" type="DateTime" name="EndTime" not-null="true" />

</class>
</hibernate-mapping>

Class: Job

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MIS.Domain.Job,MIS.Domain" table="job" lazy="true">

<id name="JobId" column="Job_ID" type="Int32" unsaved-value="0">
<generator class="hilo">
<param name="table">uniqueids</param>
<param name="column">Job_ID</param>
<param name="max_lo">0</param>
</generator>
</id>
<bag name="DowntimeList" inverse="true" lazy="true" >
<key column="Job_ID" />
<one-to-many class="MIS.Domain.Downtime,MIS.Domain" />
</bag>

<one-to-one name="MachineSetup" class="MIS.Domain.Machinesetup,MIS.Domain" />

<bag name="Runs" inverse="true" lazy="true" cascade="all-delete-orphan" >
<key column="Job_ID" />
<one-to-many class="MIS.Domain.Run,MIS.Domain" />
</bag>
<property column="jobDate" type="DateTime" name="JobDate" not-null="true" />
<property column="PartBOM_ID" type="String" name="PartbomId" length="20" />
<many-to-one name="ManArea" column="ManArea_ID" class="MIS.Domain.Manarea,MIS.Domain" not-null="true"/>
<property column="JDEOrder_ID" type="String" name="JdeOrderId" length="10" />
<many-to-one name="Machine" column="Machine_ID" class="MIS.Domain.Machine,MIS.Domain" />
<many-to-one name="Tool" column="ToolBOM_ID" class="MIS.Domain.Tool,MIS.Domain" />
<property column="PartTemp_ID" type="String" name="PartTempId" length="10" />

</class>
</hibernate-mapping>


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

Code:
Machinesetup ms = new Machinesetup(DateTime.Now, DateTime.Now);
Job jo = (Job)session.Load(typeof(Job), 6);
ms.Job = jo;
session.Save(ms);


exception that occurs:
"object was an unitialized proxy for: Job"


Name and version of the database you are using:
Mysql 5


Code:
Code:


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

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.