[hibernate-users] exclude unique index
Mark Lybarger
mlybarger at gmail.com
Mon Aug 1 15:58:29 EDT 2016
i need to add a unique index to my db like this:
CREATE UNIQUE INDEX d_7col_uni_idx ON m.dv
(fk_id, name, coalesce(make,'~~~NULL~~~'), coalesce(model,'~~~NULL~~~')
, coalesce(type,'~~~NULL~~~'), coalesce(cbo_id,-1),
coalesce(pt,'~~~NULL~~~'))
WHERE expiration_date IS NULL;
i'm using hbm2java to generate my java classes from the db by providing a
reveng.xml file to help. adding this constraint causes the generated java
code to have :
@Table(name="dv"
, uniqueConstraints = @UniqueConstraint(columnNames={"fk_id", "name",
"(COALESCE(make, '~~~NULL~~~'::character varying))", "(COALESCE(model,
'~~~NULL~~~'::character varying))", "(COALESCE(type,
'~~~NULL~~~'::character varying))", "(COALESCE((cbo_id)::integer, (-1)))",
"(COALESCE(pt, '~~~NULL~~~'::character varying))"})
)
When running my unit tests, I get an exception:
java.lang.NullPointerException
at
org.hibernate.mapping.Constraint$ColumnComparator.compare(Constraint.java:134)
My quick thought is to just get hibernate/hbm2java to ignore that
constraint and not have that annotation on the generated class. is this
possible? can i specify that the unique index should be skipped?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-users/attachments/20160801/f8826700/attachment.html
More information about the hibernate-users
mailing list