-->
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: Firebird1.5 many-to-one relation
PostPosted: Wed Mar 31, 2004 11:57 am 
Newbie

Joined: Mon Sep 08, 2003 12:37 pm
Posts: 10
Hi!

I have an address table and a department table. The department should have always one address. I insert first the address, after that i assign the address to the department, than i try to insert the department, but i've got an error saying that the addressid(department foreign key to address table) is null.
In debug i see that the address java object has the id set.....Please help me:) In the log one can see, that null is bind to the addressid in the
insert statement.....

<class
name="hibernate.generated.Tdepartment"
table="TDEPARTMENT"
>

<id
name="departmentid"
type="long"
column="DEPARTMENTID"
>
<generator class="increment" />
</id>

<property
name="name"
type="java.lang.String"
column="NAME"
not-null="true"
unique="true"
length="50"
/>
<property
name="deptkeyname"
type="java.lang.String"
column="DEPTKEYNAME"
not-null="true"
unique="true"
length="50"
/>

<!-- associations -->
<!-- bi-directional many-to-one association to Taddress -->
<many-to-one
name="taddress"
class="hibernate.generated.Taddress"
not-null="true"
>
<column name="ADDRESSID" />
</many-to-one>

</class>
</hibernate-mapping>

The code goes:

Tdepartment dept = new Tdepartment();
dept.setDeptkeyname("Test1Dept");
dept.setName("Test1Dept");
Taddress addr = new Taddress();
addr.setStreet("Test12Street");
addOneAddress(addr);
dept.setTaddress(addr);
addOneDepartment(dept);

Exception:

Caused by: org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544347. validation error for column ADDRESSID, value "*** null ***"
at org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(AbstractPreparedStatement.java:445)


In the log:

2004-03-31 17:44:24,448 [ main - net.sf.hibernate.SQL ] DEBUG - insert into TDEPARTMENT (NAME, DEPTKEYNAME, PARENTDEPTID, ADDRESSID, DEPARTMENTID) values (?, ?, ?, ?, ?)
Hibernate: insert into TDEPARTMENT (NAME, DEPTKEYNAME, PARENTDEPTID, ADDRESSID, DEPARTMENTID) values (?, ?, ?, ?, ?)
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.impl.BatcherImpl ] DEBUG - preparing statement
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.persister.EntityPersister ] DEBUG - Dehydrating entity: [ifx.cim.backend.hibernate.generated.Tdepartment#1]
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.type.StringType ] DEBUG - binding 'Test1Dept' to parameter: 1
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.type.StringType ] DEBUG - binding 'Test1Dept' to parameter: 2
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.type.LongType ] DEBUG - binding null to parameter: 3
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.type.LongType ] DEBUG - binding null to parameter: 4
2004-03-31 17:44:24,448 [ main - net.sf.hibernate.type.LongType ] DEBUG - binding '1' to parameter: 5
2004-03-31 17:44:24,464 [ main - net.sf.hibernate.impl.BatcherImpl ] DEBUG - done closing: 0 open PreparedStatements, 0 open ResultSets
2004-03-31 17:44:24,464 [ main - net.sf.hibernate.impl.BatcherImpl ] DEBUG - closing statement
2004-03-31 17:44:24,464 [ main - net.sf.hibernate.util.JDBCExceptionReporter ] DEBUG - SQL Exception


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.