• Post Reply Bookmark Topic Watch Topic
  • New Topic

UniqueConstraint for a column having OneToMany relationship.  RSS feed

Steven Rodeo
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

HI Folks,

Please advice. I am using EJB 3.0. I've been working on UniqueConstraints in DB.

I read the following http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html

It says, that to create a UniqueConstraint I specify

uniqueConstraints = {@UniqueConstraint(columnNames={"month", "day"})}

I am wondering how I can create one, when I have a OneToMany relationships between tables.

For Instance I have a table that keeps track of Directory Names ( Which are Unique, i.e the Directory Name is the Primary Key ).

Now I have another table that has list of files

So I need to create a constraint, where the Directory Name will map to only one File name, and shouldn't have any duplcate file names in this Directory. Especially when multiple threads are trying to create the same entry.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!