Quantcast
Channel: JPA - defining multi-column unique constraints - Stack Overflow
Viewing all articles
Browse latest Browse all 2

JPA - defining multi-column unique constraints

$
0
0

Is it possible using JPA to define multiple unique constraints.

@Entityclass Foo {    long id;     String name;     MyEnum type;}

Foo.id should be unique as should combinations of {Foo.name, Foo.type}.
Ex.
id, name, type
1, "name1", "type1"
2, "name1", "type2"
3, "name1", "type1" // error duplicate of id = 1

How do I achieve this using JPA annotations?

Thanks


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>