openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Polliard <tho...@polliard.com>
Subject Question about Unique Contraint
Date Wed, 20 Jan 2010 02:50:23 GMT
public class Account {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer Id = null;
	@Unique
	private String accountName = null;
	@Basic
	private Date creationDate = null;
	@ManyToMany(cascade=CascadeType.ALL)
	private List<Host> hostList = new ArrayList<Host>();

However, in the database it actually doesn't restrict the accountName but rather forces a
new ID to be generated with the same accountName. What page can I find out about creating
a Unique constraint that mimics this in pseudo database ddl

create table Account (
	Id		int4		PRIMARY KEY,
	accountname	varchar(255)	NOT NULL UNIQUE,
	.....


Thanks for the assistance.

Thomas


PS:

http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_mapping_jpa.html#ref_guide_mapping_jpa_unique

Doesn't appear to be the proper Annotation.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message