java - How to map an interger key to an @ManyToOne object within the same @Entity? -


is possible have optional integer column map @manytoone object @ same time?

table:

id,name,catalogid

accordingly class:

@entity class mytable {     @id     private long id;     private string name;      private integer catalogid;        @manytoone     @joincolum(name = "catalogid", foreignkey = @foreignkey(name="fk_catalog"), nullable=true)     private mycatalog catalog; }  @entity class mycatalog {     @id     private int catalogid;      //some more fields...      @onetomany(mappedby = "catalog")     private set<mytable> mytables; } 

when create object, know catalogid already, foreign mapped table not yet have content catalogid.

question: possible define @manytoone optional? thus, set catalogid value, let hibernate create object if can linked foreign table?


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -