Hi,
I have an entity "Asset" that contains a list of other entities "Business". This realizes a many-to-many association.
The table is named "ASSET_BUSINESSES" and has two additional columns "ACTIVATED" and "DATE". Persisting a new Asset with existing Businesses results in an Exception due to a NULL value for ACTIVATED (and DATE I assume).
What can I do to tell Hibernate to populate the ACTIVATED and DATE field before persisting into the many-to-many-table?
Here is my Asset entity
Code:
............
@ManyToMany(targetEntity = Business.class)
@JoinTable(name = "ASSET_BUSINESSES", joinColumns = { @JoinColumn(name = "ASSETID") }, inverseJoinColumns = { @JoinColumn(name = "BUSINESSID") })
@Cascade(value = { org.hibernate.annotations.CascadeType.SAVE_UPDATE,
org.hibernate.annotations.CascadeType.MERGE,
org.hibernate.annotations.CascadeType.PERSIST })
private List<Business> businesses;
.............
The Exception:
Quote:
java.sql.BatchUpdateException: ORA-01400: Einfügen von NULL in ("ASSETREGISTER_DBA"."ASSET_BUSINESSES"."ACTIVATED") nicht möglich
(meaning NULL is not a valid value for the field "activated" in the join table "asset_businesses").
I think the problem is that my many-to-many table not only contains an "asset" column and a "business" column, but additionally another "activated" column. Hibernate does not seem to populate this field with a value before trying to persist.
What can I do?