[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2511) generated="insert/always" ignored for property in composite-element?
Peter Ghosh (JIRA)
noreply at atlassian.com
Tue Jan 10 16:29:10 EST 2012
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45077#comment-45077 ]
Peter Ghosh commented on HHH-2511:
----------------------------------
This seems to still be broken in release 3.3.2.
> generated="insert/always" ignored for property in composite-element?
> --------------------------------------------------------------------
>
> Key: HHH-2511
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2511
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.2.2
> Environment: Hibernate 3.2.2, Windows XP SP2, Oracle 9i
> Reporter: James Garrison
> Priority: Minor
> Attachments: HelloWorldAgain.hbm.xml, HelloWorldAgain.java, HelloWorldAgainTest.java, hibernate.cfg.xml
>
>
> I have a composite-element (in an idbag) that has a db-generated timestamp
> property. I have defined the property with update="false" insert="false" generated="insert",
> but Hibernate is trying to insert a null value when saving a transient object.
> See below, the "createTs" property (column=CREATE_TS) in the "comments"
> composite-element.
> DDL:
> create table CR_COMMENT
> (
> COMMENT_ID integer not null,
> REQ_ID integer not null,
> CREATE_TS timestamp default sysdate not null,
> SECTION_ID char(1) not null,
> USER_ID varchar2(20) not null,
> TEXT varchar2(4000) not null,
> primary key(COMMENT_ID),
> foreign key(REQ_ID) references CR_REQUEST (REQ_ID) on delete cascade
> );
> 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">
> <hibernate-mapping package="com.wholefoods.ittoolkit.ws.ccf">
> <class name="Request" table="CR_REQUEST">
>
> <id name="reqId" column="REQ_ID" type="long">
> <generator class="sequence">
> <param name="sequence">CR_REQUEST_ID</param>
> </generator>
> </id>
> [snip]
> <idbag name="comments" table="CR_COMMENT">
> <collection-id type="long" column="COMMENT_ID">
> <generator class="sequence">
> <param name="sequence">CR_COMMENT_ID</param>
> </generator>
> </collection-id>
>
> <key column="REQ_ID" />
>
> <composite-element class="Comment">
> <property name="createTs" column="CREATE_TS"
> type="calendar"
> access="field"
> update="false"
> insert="false"
> generated="insert" />
> <property name="sectionId" column="SECTION_ID" />
> <property name="userId" column="USER_ID" />
> <property name="text" column="TEXT"/>
> </composite-element>
> </idbag>
> </class>
> </hibernate-mapping>
> Log Output:
> Hibernate:
> /* insert collection
> row com.wholefoods.ittoolkit.ws.ccf.Request.comments */ insert
> into
> ITTOOLKIT.CR_COMMENT
> (REQ_ID, COMMENT_ID, CREATE_TS, SECTION_ID, USER_ID, TEXT)
> values
> (?, ?, ?, ?, ?, ?)
> 10:15:01,659 DEBUG org.hibernate.jdbc.AbstractBatcher:476 - preparing statement
> 10:15:01,675 DEBUG org.hibernate.type.LongType:133 - binding '47' to parameter: 1
> 10:15:01,675 DEBUG org.hibernate.type.LongType:133 - binding '7' to parameter: 2
> 10:15:01,675 DEBUG org.hibernate.type.CalendarType:126 - binding null to parameter: 3
> 10:15:01,675 DEBUG org.hibernate.type.StringType:133 - binding 'A' to parameter: 4
> 10:15:01,690 DEBUG org.hibernate.type.StringType:133 - binding 'garrisoj' to parameter: 5
> 10:15:01,690 DEBUG org.hibernate.type.StringType:133 - binding 'This is a test comment' to parameter: 6
> 10:15:01,690 DEBUG org.hibernate.persister.collection.AbstractCollectionPersister:1172 - done inserting collection: 1 rows inserted
> 10:15:01,690 DEBUG org.hibernate.jdbc.AbstractBatcher:44 - Executing batch size: 1
> 10:15:01,737 DEBUG org.hibernate.jdbc.AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
> 10:15:01,737 DEBUG org.hibernate.jdbc.AbstractBatcher:525 - closing statement
> 10:15:01,768 DEBUG org.hibernate.util.JDBCExceptionReporter:69 - Could not execute JDBC batch update
> [/* insert collection row com.wholefoods.ittoolkit.ws.ccf.Request.comments */
> insert into ITTOOLKIT.CR_COMMENT (REQ_ID, COMMENT_ID, CREATE_TS, SECTION_ID, USER_ID, TEXT)
> values (?, ?, ?, ?, ?, ?)]
> java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into ("ITTOOLKIT"."CR_COMMENT"."CREATE_TS")
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list