• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@UniqueConstraint

 
Tomek Brzeczyszczykiewicz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

having in the code:




and later in the class:



Can any one explain why in postgres it's generating two constraints:
- contact_code_key UNIQUE (code, customer_code),
- contact_code_key1 UNIQUE (code)

should it be just first one? or I'm missing something here?

Thanks for any help
Tomek
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Tomek ABCDF"

Please click on the My Profile link above and change your display name to meet the JavaRanch Naming Policy of using your real first and real last names.

Thank you for your understanding.

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is interesting consider that you specifically said that one field itself is not unique.

So, we can gather that the first constraint is in regards to the class level annotation.

The second one should just have that it cannot be null and nothing about it being unique. What happens when you remove the unique=false part?

Mark
 
Tomek Brzeczyszczykiewicz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replay.

I found is the problem.

in Order entity I have:


so it assumes that the column must be unique, and I understand why, but is there anyway to get around this?

Thank you,
Tomek
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic