-->
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.  [ 4 posts ] 
Author Message
 Post subject: Embeddable PK with generatedValue
PostPosted: Wed Jan 09, 2008 6:54 am 
Beginner
Beginner

Joined: Sat Oct 20, 2007 8:28 am
Posts: 28
Code:
Cannot insert explicit value for identity column in table 'task' when IDENTITY_INSERT is set to OFF


i have a class that has an idclass , the@Id @GeneratedValuestrategy=GenerationType.AUTO) defined in class and the pkclass is compised of this property and another one ...
is this not possible ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 11:20 am 
Beginner
Beginner

Joined: Sat Oct 20, 2007 8:28 am
Posts: 28
i wasn't specific enough :

Code:
@Entity
@Table(name="CORETASK")
@IdClass(CoreTaskPK.class)
@Inheritance(strategy=InheritanceType.JOINED)
public class CoreTask
      {
   
   //Task general Data
   private Integer coreTaskInternalKey;
   private Integer coreTaskMemberInternalKey;
                @Id
                  @GeneratedValue(strategy=GenerationType.AUTO)
   public Integer getCoreTaskInternalKey() {return coreTaskInternalKey;}
   public void setCoreTaskInternalKey(Integer coreTaskInternalKey) {this.coreTaskInternalKey = coreTaskInternalKey;}

   @Id
   public Integer getCoreTaskMemberInternalKey() {return coreTaskMemberInternalKey;}
   public void setCoreTaskMemberInternalKey(Integer coreTaskMemberInternalKey) {this.coreTaskMemberInternalKey = coreTaskMemberInternalKey;}





Code:
public class CoreTaskPK
   implements Serializable{

   private Integer coreTaskInternalKey;
   private Integer coreTaskMemberInternalKey;
   
   @Column(name="coretaskinternalkey")
   public Integer getCoreTaskInternalKey() {return coreTaskInternalKey;}
   public void setCoreTaskInternalKey(Integer coreTaskInternalKey) {this.coreTaskInternalKey = coreTaskInternalKey;}
   
   @Column(name="memberinternalkey")
   public Integer getCoreTaskMemberInternalKey() {return coreTaskMemberInternalKey;}
   public void setCoreTaskMemberInternalKey(Integer coreTaskMemberInternalKey) {
      this.coreTaskMemberInternalKey = coreTaskMemberInternalKey;
   }



using mssql 2005
i'm trying to
Coretask coreTask = new CoreTask();
coreTaskService.save(coreTask);
and getting the above exception ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 10:14 pm 
Regular
Regular

Joined: Sat Nov 25, 2006 11:37 am
Posts: 72
Use

@GeneratedValue(strategy = GenerationType.IDENTITY)

instead of GenerationType.AUTO for SQL Server identity columns.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 3:42 am 
Beginner
Beginner

Joined: Sat Oct 20, 2007 8:28 am
Posts: 28
malm66 wrote:
Use

@GeneratedValue(strategy = GenerationType.IDENTITY)

instead of GenerationType.AUTO for SQL Server identity columns.


i did and allso tried with @embeddedid and tried annotating only here only there and both nothing seems to work ?? is this a hibernate bug ?
because when i try to insert without the generated value it's ok

i think the dialect is wrong it still uses the identity colum in the insert (...) columns even tough it shouldn't using SQLSERVERDIALCT


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.