Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Add Primary key on ManyToMany (for Publication)

$
0
0

I have a ManyToMany relation between two entity

@javax.persistence.Entity
@Table(name = "t_aircraft_model")
public class AircraftModel extends DbObject {

    @ManyToMany(fetch=FetchType.LAZY)
    @JoinTable(name = "t_aircraft_model_entity", joinColumns = { @JoinColumn(name = "aircraft_model_uid", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "entity_id_LDAP", nullable = false) })
    private List<com.airbushelicopter.ahead.db.pojo.Entity> entities ;

But sqlServer doesn't allow me to publish the intermediate table : t_aircraft_model_entity

new publication

I thought about 2 solutions

  • Both column of the table the t_aircraft_model_entity become the primary key (ok in my case a aircraft can't be linked multiple time to the same entity)
  • I add a 3rd column (id) which will be the primary key
  • Or ?

But I have no idea how I can do this with hibernate and annotation.

thanks !


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>