|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Hibernate Unique index for many-to-many associationHi,
I have the following class: /** * @hibernate.class table="movie" */ public class Movie extends BaseBusinessObject implements Serializable { /** * @hibernate.property * @hibernate.column name="name" not-null="true" length="30" unique="true" */ String name; /** * @hibernate.property * @hibernate.column name="dateofissue" not-null="true" */ Date dateOfIssue; /** * @hibernate.property * @hibernate.column name="length" not-null="true" */ Integer length; /** * @hibernate.many-to-many class="com.acasa.annotation.pojo.Actor" column="actor_id" foreign-key="FK_ACTOR" * @hibernate.key column="movie_id" foreign-key="FK_MOVIE" * @hibernate.list table="movie_details" lazy="true" inverse="true" * @hibernate.list-index column="idx" */ java.util.List<Actor> distribution; /** * @hibernate.many-to-one * class="com.acasa.annotation.pojo.Producer" * foreign-key="FK_PRODUCER" */ Producer producer; } Hibernate will create these 2 tables: create table movie (id int4 not null, version int4 not null, name varchar(30) not null unique, dateofissue timestamp not null, length int4 not null, producer int4, primary key (id)); create table movie_details (movie_id int4 not null, actor_id int4 not null, idx int4 not null); What hibernate tags should I use in order to get hibernate to create an unique constraint on columns "movie_id" and "actor_id" for table "movie_details"? Thanks, Vasile |
|
|
Re: Hibernate Unique index for many-to-many associationThis question is better asked on xdoclet-plugins
mailing list, which can be subscribed fromSF project: http://www.sourceforge.net/projects/xdoclet-plugins/ And @hibernate.many-to-many accepts parameter "unique" ( which is false by default ) http://xdoclet.codehaus.org/HibernateTags#HibernateTags-hibernate.manytomany regards, --- Vasile <vasile.purdila@...> wrote: > > Hi, > > I have the following class: > > /** > * @hibernate.class table="movie" > */ > public class Movie extends BaseBusinessObject > implements Serializable > { > /** > * @hibernate.property > * @hibernate.column name="name" not-null="true" > length="30" unique="true" > */ > String name; > > /** > * @hibernate.property > * @hibernate.column name="dateofissue" > not-null="true" > */ > Date dateOfIssue; > > /** > * @hibernate.property > * @hibernate.column name="length" not-null="true" > */ > Integer length; > > /** > * @hibernate.many-to-many > class="com.acasa.annotation.pojo.Actor" > column="actor_id" foreign-key="FK_ACTOR" > * @hibernate.key column="movie_id" > foreign-key="FK_MOVIE" > * @hibernate.list table="movie_details" > lazy="true" inverse="true" > * @hibernate.list-index column="idx" > */ > java.util.List<Actor> distribution; > > /** > * @hibernate.many-to-one > * class="com.acasa.annotation.pojo.Producer" > * foreign-key="FK_PRODUCER" > */ > Producer producer; > } > > Hibernate will create these 2 tables: > > create table movie (id int4 not null, version int4 > not null, name > varchar(30) not null unique, dateofissue timestamp > not null, length int4 not > null, producer int4, primary key (id)); > create table movie_details (movie_id int4 not null, > actor_id int4 not null, > idx int4 not null); > > What hibernate tags should I use in order to get > hibernate to create an > unique constraint on columns "movie_id" and > "actor_id" for table > "movie_details"? > > Thanks, > Vasile > -- > View this message in context: > > Sent from the xdoclet - user forum at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > ----[ Konstantin Pribluda http://www.pribluda.de ]---------------- Still using XDoclet 1.x? XDoclet 2 is released and of production quality. check it out: http://xdoclet.codehaus.org __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Free Forum Powered by Nabble | Forum Help |