-->
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.  [ 2 posts ] 
Author Message
 Post subject: Two @Id anntotations in one class
PostPosted: Wed Apr 30, 2008 4:35 am 
Newbie

Joined: Wed Apr 30, 2008 4:14 am
Posts: 1
Hi all. I have problem:
my class:

@Entity
@Table(name = "productTable")
@javax.persistence.TableGenerator(name = "contentGen", table = "contentIdGen", pkColumnName = "keyCol", valueColumnName = "val", pkColumnValue = "content")
public class Product {
private Long id;
private String name;
private Long contentId;
......
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
.....
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "contentGen")
public long getContentId() {
return contentId;
}
.....
.....
}

When I create my class product and save it into DB i getting this error:

Hibernate: insert into productTable (id, name) values (null, ?)
16:57:11,874 WARN [JDBCExceptionReporter] SQL Error: -10, SQLState: 23000
16:57:11,875 ERROR [JDBCExceptionReporter] Attempt to insert null into a non-nullable column: column: CONTENTID table: PRODUCTTABLE in statement [insert into productTable (id, name) values (null, ?)]
org.hibernate.exception.ConstraintViolationException: could not insert...

In error stack trace i'm not view contentId field name -> (productTable (id, name))

Hibernate version:
3.2.6GA

Name and version of the database you are using:
HSQLDB 1.8.0.7 (for tests) and MSSQL 2005


Top
 Profile  
 
 Post subject: question
PostPosted: Wed Apr 30, 2008 6:55 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
1. could you pls post the DDL that you use?
2. who created the DDL? you? hibernate?


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

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.