[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6044) Compound ID with auto-generated part produces exception

Anne Buit (JIRA) noreply at atlassian.com
Tue May 15 03:19:13 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-6044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46665#comment-46665 ] 

Anne Buit commented on HHH-6044:
--------------------------------

This bug is still present in version 4.1.0

> Compound ID with auto-generated part produces exception
> -------------------------------------------------------
>
>                 Key: HHH-6044
>                 URL: https://hibernate.onjira.com/browse/HHH-6044
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.6
>         Environment: java 6.23 64bit
> Hibernate 3.5.6
>            Reporter: Alex Shubert
>
> @Entity
> public class TestRow implements Serializable {
>     @Id
>     @GeneratedValue(strategy = GenerationType.IDENTITY)
>     private Long id;
>     @Id
>     private Long version;
>    setters and getters are ommited for it's triviality    
> }
> 2. creating database and table by hand 
> #mysql -u username ... 
> create table F_TESTROW (ID bigint not null auto_increment, VERSION  bigint not null, primary key (VERSION, ID))
> TestRow testRow = new TestRow();
> testRow.setVersion(2L);
> testRow.setAddr("somewhere");
> sessionFactory.openSession().save(testRow);
> produces 
> java.lang.IllegalArgumentException: Can not set java.lang.Long field ru.kctsoft.fenestro.domain.strategy.TestRow.id to org.hibernate.id.IdentifierGeneratorHelper$2
> 	at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:139)
> This is kinda frustrating.
> http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/ 
> 2.2.3.2.4. Partial identifier generation
> Hibernate supports the automatic generation of some of the identifier properties. Simply use the @GeneratedValue annotation on one or several id properties.

--
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