I'm trying to add a sheet with an association to a 'guido'. I call setGuido(guido) on the sheet object then I try to save the sheet, the columns of the sheet are inserted except for the guido_id column. Why isn't the guido_id column inserted(please see generated SQL).
Hibernate version:
3.1
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jan 16, 2006 10:45:02 PM by Hibernate Tools 3.1.0 beta1JBIDERC2 -->
<hibernate-mapping>
<class name="com.allentown.db.Guido" table="guido" schema="public">
<composite-id name="id" class="com.allentown.db.GuidoId">
<key-property name="acId" type="integer">
<column name="ac_id" />
</key-property>
<key-property name="id" type="integer">
<column name="id" />
</key-property>
</composite-id>
<many-to-one name="accountUser" class="com.allentown.db.AccountUser" update="false" insert="false" fetch="select">
<column name="ac_id" not-null="true" />
<column name="account_user_id" />
</many-to-one>
<many-to-one name="address" class="com.allentown.db.Address" fetch="select">
<column name="address_id" />
</many-to-one>
<many-to-one name="account" class="com.allentown.db.Account" update="false" insert="false" fetch="select">
<column name="ac_id" not-null="true" />
</many-to-one>
<property name="contactName" type="string">
<column name="contact_name" length="100" />
</property>
<property name="companyName" type="string">
<column name="company_name" length="100" />
</property>
<property name="cut" type="big_decimal">
<column name="cut" precision="10" scale="5" />
</property>
<property name="tz" type="integer">
<column name="tz" />
</property>
<set name="sheetMoneies" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="guido_id" />
</key>
<one-to-many class="com.allentown.db.SheetMoney" />
</set>
<set name="sheets" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="guido_id" />
</key>
<one-to-many class="com.allentown.db.Sheet" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jan 16, 2006 10:45:02 PM by Hibernate Tools 3.1.0 beta1JBIDERC2 -->
<hibernate-mapping>
<class name="com.allentown.db.Sheet" table="sheet" schema="public">
<composite-id name="id" class="com.allentown.db.SheetId">
<key-property name="acId" type="integer">
<column name="ac_id" />
</key-property>
<key-property name="id" type="integer">
<column name="id" />
</key-property>
</composite-id>
<many-to-one name="guido" class="com.allentown.db.Guido" update="false" insert="false" fetch="select">
<column name="ac_id" not-null="true" />
<column name="guido_id" />
</many-to-one>
<many-to-one name="sheettype" class="com.allentown.db.Sheettype" fetch="select">
<column name="ad_type_id" />
</many-to-one>
<many-to-one name="account" class="com.allentown.db.Account" update="false" insert="false" fetch="select">
<column name="ac_id" not-null="true" />
</many-to-one>
<property name="makeGood" type="integer">
<column name="make_good" />
</property>
<property name="name" type="string">
<column name="name" length="100" />
</property>
<property name="expireDate" type="timestamp">
<column name="expire_date" length="8" />
</property>
<property name="status" type="string">
<column name="status" length="10" />
</property>
<set name="sheetMoneies" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="sheet_id" not-null="true" />
</key>
<one-to-many class="com.allentown.db.SheetMoney" />
</set>
<set name="activityLogsForActivityLogAcIdFkey2" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="site_id" not-null="true" />
</key>
<one-to-many class="com.allentown.db.ActivityLog" />
</set>
<set name="totalLogsForTotalLogAcIdFkey2" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="site_id" not-null="true" />
</key>
<one-to-many class="com.allentown.db.TotalLog" />
</set>
<set name="activityLogsForActivityLogAcIdFkey1" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="sheet_id" not-null="true" />
</key>
<one-to-many class="com.allentown.db.ActivityLog" />
</set>
<set name="baskets" inverse="true">
<key>
<column name="ac_id" not-null="true" />
<column name="sheet_id" />
</key>
<one-to-many class="com.allentown.db.Basket" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Session s = HibernateUtil.currentSession();
Guido a = (Guido) s.load(Guido.class,new GuidoId(1,1));
Account ac = (Account)s.load(Account.class,1);
newSheet.setId(new SheetId(1,1));
newSheet.setGuido(a);
newSheet.setAccount(ac);
newSheet.setSheettype((Sheettype)s.load(Sheettype.class,0));
newSheet.setStatus("blah");
newSheet.setName("name");
s.save(newSheet);
Later I commit the transaction
Full stack trace of any exception that occurs:Name and version of the database you are using:Postgresql 8.0.5
The generated SQL (show_sql=true):Hibernate: insert into public.sheet (ad_type_id, make_good, name, expire_date, status, ac_id, id) values (?, ?, ?, ?, ?, ?, ?)
(guido_id column is not being inserted)
Debug level Hibernate log excerpt:Code:
Filter: opening session
01:44:02,218 DEBUG JDBCTransaction:54 - begin
01:44:02,219 DEBUG ConnectionManager:313 - opening JDBC connection
01:44:02,219 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 1
01:44:02,220 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
01:44:02,319 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:postgresql://127.0.0.1/ads, Isolation Level: 2
01:44:02,320 DEBUG JDBCTransaction:59 - current autocommit status: false
01:44:02,325 DEBUG JDBCContext:202 - after transaction begin
In security filter for guido
01:44:02,325 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:44:02,326 DEBUG SQL:346 - select accountuse0_.ac_id as ac1_6_0_, accountuse0_.id as id6_0_, accountuse0_.username as username6_0_, accountuse0_.password as password6_0_, accountuse0_.tz as tz6_0_ from public.account_user accountuse0_ where accountuse0_.ac_id=? and accountuse0_.id=?
Hibernate: select accountuse0_.ac_id as ac1_6_0_, accountuse0_.id as id6_0_, accountuse0_.username as username6_0_, accountuse0_.password as password6_0_, accountuse0_.tz as tz6_0_ from public.account_user accountuse0_ where accountuse0_.ac_id=? and accountuse0_.id=?
01:44:02,327 DEBUG AbstractBatcher:424 - preparing statement
01:44:02,327 DEBUG IntegerType:79 - binding '1' to parameter: 1
01:44:02,328 DEBUG IntegerType:79 - binding '1' to parameter: 2
01:44:02,347 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
01:44:02,357 DEBUG IntegerType:123 - returning '1' as column: ac1_6_0_
01:44:02,357 DEBUG StringType:123 - returning 'JBob' as column: username6_0_
01:44:02,358 DEBUG StringType:123 - returning 'p' as column: password6_0_
01:44:02,359 DEBUG IntegerType:123 - returning '1' as column: tz6_0_
01:44:02,359 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
01:44:02,360 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:44:02,361 DEBUG AbstractBatcher:470 - closing statement
01:44:02,362 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:44:02,363 DEBUG SQL:346 - select guido0_.ac_id as ac1_8_0_, guido0_.id as id8_0_, guido0_.account_user_id as account3_8_0_, guido0_.address_id as address4_8_0_, guido0_.contact_name as contact5_8_0_, guido0_.company_name as company6_8_0_, guido0_.cut as cut8_0_, guido0_.tz as tz8_0_ from public.guido guido0_ where guido0_.ac_id=? and guido0_.id=?
Hibernate: select guido0_.ac_id as ac1_8_0_, guido0_.id as id8_0_, guido0_.account_user_id as account3_8_0_, guido0_.address_id as address4_8_0_, guido0_.contact_name as contact5_8_0_, guido0_.company_name as company6_8_0_, guido0_.cut as cut8_0_, guido0_.tz as tz8_0_ from public.guido guido0_ where guido0_.ac_id=? and guido0_.id=?
01:44:02,363 DEBUG AbstractBatcher:424 - preparing statement
01:44:02,365 DEBUG IntegerType:79 - binding '1' to parameter: 1
01:44:02,366 DEBUG IntegerType:79 - binding '1' to parameter: 2
01:44:02,368 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
01:44:02,369 DEBUG IntegerType:123 - returning '1' as column: ac1_8_0_
01:44:02,370 DEBUG IntegerType:123 - returning '1' as column: account3_8_0_
01:44:02,371 DEBUG IntegerType:123 - returning '1' as column: address4_8_0_
01:44:02,372 DEBUG IntegerType:123 - returning '1' as column: ac1_8_0_
01:44:02,372 DEBUG StringType:123 - returning 'Mr. Guido' as column: contact5_8_0_
01:44:02,379 DEBUG StringType:123 - returning 'TheCompanyName' as column: company6_8_0_
01:44:02,379 DEBUG BigDecimalType:123 - returning '0.00000' as column: cut8_0_
01:44:02,380 DEBUG IntegerType:123 - returning '1' as column: tz8_0_
01:44:02,381 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
01:44:02,382 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:44:02,382 DEBUG AbstractBatcher:470 - closing statement
01:44:02,383 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:44:02,384 DEBUG SQL:346 - select guido0_.ac_id as ac1_1_, guido0_.account_user_id as account3_1_, guido0_.id as id1_, guido0_.ac_id as ac1_8_0_, guido0_.id as id8_0_, guido0_.account_user_id as account3_8_0_, guido0_.address_id as address4_8_0_, guido0_.contact_name as contact5_8_0_, guido0_.company_name as company6_8_0_, guido0_.cut as cut8_0_, guido0_.tz as tz8_0_ from public.guido guido0_ where guido0_.ac_id=? and guido0_.account_user_id=?
Hibernate: select guido0_.ac_id as ac1_1_, guido0_.account_user_id as account3_1_, guido0_.id as id1_, guido0_.ac_id as ac1_8_0_, guido0_.id as id8_0_, guido0_.account_user_id as account3_8_0_, guido0_.address_id as address4_8_0_, guido0_.contact_name as contact5_8_0_, guido0_.company_name as company6_8_0_, guido0_.cut as cut8_0_, guido0_.tz as tz8_0_ from public.guido guido0_ where guido0_.ac_id=? and guido0_.account_user_id=?
01:44:02,385 DEBUG AbstractBatcher:424 - preparing statement
01:44:02,385 DEBUG IntegerType:79 - binding '1' to parameter: 1
01:44:02,386 DEBUG IntegerType:79 - binding '1' to parameter: 2
01:44:02,388 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
01:44:02,389 DEBUG IntegerType:123 - returning '1' as column: ac1_8_0_
01:44:02,390 DEBUG IntegerType:123 - returning '1' as column: id8_0_
01:44:02,390 DEBUG IntegerType:123 - returning '1' as column: ac1_1_
01:44:02,391 DEBUG IntegerType:123 - returning '1' as column: account3_1_
01:44:02,393 DEBUG IntegerType:123 - returning '1' as column: ac1_1_
01:44:02,396 DEBUG IntegerType:123 - returning '1' as column: id1_
01:44:02,397 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
01:44:02,398 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:44:02,398 DEBUG AbstractBatcher:470 - closing statement
01:44:02,399 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:44:02,400 DEBUG SQL:346 - select account0_.id as id16_0_, account0_.address_id as address2_16_0_, account0_.name as name16_0_, account0_.contact_name as contact4_16_0_, account0_.core_server_id as core5_16_0_, account0_.tz as tz16_0_ from public.account account0_ where account0_.id=?
Hibernate: select account0_.id as id16_0_, account0_.address_id as address2_16_0_, account0_.name as name16_0_, account0_.contact_name as contact4_16_0_, account0_.core_server_id as core5_16_0_, account0_.tz as tz16_0_ from public.account account0_ where account0_.id=?
01:44:02,405 DEBUG AbstractBatcher:424 - preparing statement
01:44:02,406 DEBUG IntegerType:79 - binding '1' to parameter: 1
01:44:02,408 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
01:44:02,409 DEBUG IntegerType:123 - returning '1' as column: address2_16_0_
01:44:02,410 DEBUG StringType:123 - returning 'jc' as column: name16_0_
01:44:02,410 DEBUG StringType:123 - returning 'Robert' as column: contact4_16_0_
01:44:02,411 DEBUG IntegerType:123 - returning '1' as column: core5_16_0_
01:44:02,411 DEBUG IntegerType:116 - returning null as column: tz16_0_
01:44:02,418 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
01:44:02,419 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:44:02,420 DEBUG AbstractBatcher:470 - closing statement
Verified auth of this user: JBob for guido Mr. Guido, account jc
In NewSheetSubmitAction
01:44:02,421 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:44:02,422 DEBUG SQL:346 - select sheettype0_.id as id20_0_, sheettype0_.width as width20_0_, sheettype0_.height as height20_0_, sheettype0_.description as descript4_20_0_ from public.ad_type sheettype0_ where sheettype0_.id=?
Hibernate: select sheettype0_.id as id20_0_, sheettype0_.width as width20_0_, sheettype0_.height as height20_0_, sheettype0_.description as descript4_20_0_ from public.ad_type sheettype0_ where sheettype0_.id=?
01:44:02,425 DEBUG AbstractBatcher:424 - preparing statement
01:44:02,426 DEBUG IntegerType:79 - binding '2' to parameter: 1
01:44:02,427 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
01:44:02,428 DEBUG IntegerType:123 - returning '120' as column: width20_0_
01:44:02,429 DEBUG IntegerType:123 - returning '600' as column: height20_0_
01:44:02,431 DEBUG StringType:123 - returning '120x600 Skyscraper' as column: descript4_20_0_
01:44:02,432 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
01:44:02,433 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:44:02,433 DEBUG AbstractBatcher:470 - closing statement
Added sheet 1, adv acct was 1
Filter: closing session
01:44:02,478 DEBUG JDBCTransaction:103 - commit
01:44:02,480 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:44:02,480 DEBUG SQL:346 - insert into public.sheet (ad_type_id, make_good, name, expire_date, status, ac_id, id) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into public.sheet (ad_type_id, make_good, name, expire_date, status, ac_id, id) values (?, ?, ?, ?, ?, ?, ?)
01:44:02,481 DEBUG AbstractBatcher:424 - preparing statement
01:44:02,481 DEBUG IntegerType:79 - binding '0' to parameter: 1
01:44:02,482 DEBUG IntegerType:71 - binding null to parameter: 2
01:44:02,482 DEBUG StringType:79 - binding 'name' to parameter: 3
01:44:02,483 DEBUG TimestampType:71 - binding null to parameter: 4
01:44:02,483 DEBUG StringType:79 - binding 'blah' to parameter: 5
01:44:02,484 DEBUG IntegerType:79 - binding '1' to parameter: 6
01:44:02,485 DEBUG IntegerType:79 - binding '1' to parameter: 7
01:44:02,488 DEBUG AbstractBatcher:28 - Adding to batch
01:44:02,489 DEBUG AbstractBatcher:55 - Executing batch size: 1
01:44:02,491 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:44:02,492 DEBUG AbstractBatcher:470 - closing statement
01:44:02,493 DEBUG JDBCContext:193 - before transaction completion
01:44:02,570 DEBUG JDBCTransaction:116 - committed JDBC Connection
01:44:02,571 DEBUG JDBCContext:207 - after transaction completion
01:44:02,571 DEBUG ConnectionManager:296 - aggressively releasing JDBC connection
01:44:02,572 DEBUG ConnectionManager:333 - closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
01:44:02,572 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
01:44:02,573 DEBUG ConnectionManager:267 - connection already null in cleanup : no action