Hi,
i have a little mapping problem...
Code:
@Entity
@Table
public class VersionDescriptor {
...
@OneToMany(fetch = FetchType.LAZY)
@Column(nullable=true)
private List<VersionDescriptor> predecessors = new ArrayList<VersionDescriptor>();
...
@OneToMany(cascade={CascadeType.ALL}, fetch = FetchType.LAZY)
@Column(nullable=true)
private List<VersionDescriptor> sucessors = new ArrayList<VersionDescriptor>();
...
}
is not mapped like exspected to the database. That means all (not listed attributes) are mapped to a VERSIONDESCRIPTOR table and for the predecessor and successor list a second table VERSIONDESCRIPTOR _VERSIONDESCRIPTOR is created that contains versiondescriptor_uid, predecessor_uid and successor_uid.
BUT the problem is that these columns are configured as NOT NULL instead of NULLABLE. What can i do to resolve this issue ? For example - I am getting errors if i try to insert only a successor, because Hibernate tells me that there is no defaultvalue for the other (predecessor)...
Removing this restriction directly on the DB works fine and i can produce something like this:
Code:
versiondescriptor_uid | predecessor_uid | successor_uid
4 | 5 | NULL
5 | NULL |4
5 | 6 | NULL
...
I already thought about telling Hibernate to create two seperate tables for it... but how? or is there a simpler solution ?
Cheers Tobias