OneToMany association with optional collection How to do this?
I have Article class with unidirectional association to Zone via link table: @OneToMany(fetch = FetchType.LAZY) @JoinTable(name = "LNARTICLEZONE", joinColumns = { @JoinColumn(name = "ARTICLEOID") }, inverseJoinColumns = { @JoinColumn(name = "ZONEOID") }) public Set<Zone> getZones()
Zone does not know about Article.
What I want is to insert article in database without zones. Since in some use cases it is not needed. With above mappings I get two inserts (as expected): insert into article.. which is good :) and insert into lnarticlezone which I would like to avoid since it should be optional!
Any ideas?
|