• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TOPLINK-41 for SQL Server 2005 and Identity Column

 
Russell Ray
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have mapped several entities to a SQL Server 2005 database. I am using the Identity column as a sequence generator for the primary key in each table.

This is how I do it:

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="server_asset_id", unique=true, nullable=false, precision=18, scale=0)
public Long getServerAssetId() {
return this.serverAssetId;
}


However, I am getting the below error:
Exception [TOPLINK-41] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: A non-read-only mapping must be defined for the sequence number field.
Descriptor: RelationalDescriptor(jtdi.cm.ejb.bean.entity.ServerAsset --> [DatabaseTable(jtdi_cm_db.dbo.server_asset)])


When I go look at the table properties in SQL Server 2005, I see the identity is setup properly.

Am I doing this wrong? Any suggestions would be greatly appreciated. Thank you for taking the time to read my post.

Russ
 
Russell Ray
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This annotation is correct. The underlining problem was a targetEntity had the wrong enitity causing this problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic