EmbeddableId should be mapped with insert="false" update="false" - java

I have the following entities: Match with embeddableId MatchKey and a polymorphic entity OrganisationMatch
Hibernate is blowing up with Repeated column in mapping for entity: net.satago.web.entities.OrganisationMatch column: referenceKind (should be mapped with insert="false" update="false")
I don't know what is wrong, can I not use #DiscriminatorColumn annotations on #EmbeddableIds parts and make them not insertable nor updatable?
It works fine if the column to discriminate by is not part of an #EmbeddableId but just a regular column on the Match entity.
#Embeddable
#ParametersAreNonnullByDefault
public class MatchKey implements Serializable
{
private static final long serialVersionUID = 7619427612022530146L;
#Column(insertable = false, updatable = false)
#Enumerated(STRING)
private MatchableEntityKind referenceKind;
private Long referenceId;
public MatchKey()
{
// For JPA
}
public MatchKey(OrganisationId organisationId)
{
this.referenceKind = ORGANISATION;
this.referenceId = organisationId.getId();
}
public MatchableEntityKind getReferenceKind()
{
return referenceKind;
}
public void setReferenceKind(MatchableEntityKind referenceKind)
{
this.referenceKind = referenceKind;
}
public Long getReferenceId()
{
return referenceId;
}
public void setReferenceId(Long referenceId)
{
this.referenceId = referenceId;
}
#Override
public boolean equals(Object obj)
{
if (obj instanceof MatchKey)
{
MatchKey that = (MatchKey) obj;
return this.referenceKind == that.referenceKind &&
Objects.equals(this.referenceId, that.referenceId);
}
return false;
}
#Override
public int hashCode()
{
return Objects.hash(referenceKind, referenceId);
}
}
#Entity
#Table(name = TABLE_NAME)
#Inheritance(strategy = SINGLE_TABLE)
#DiscriminatorColumn(name = "reference_kind", discriminatorType = DiscriminatorType.STRING)
#ParametersAreNonnullByDefault
public class Match implements EntityModel<MatchKey>
{
static final String TABLE_NAME = "matches";
#EmbeddedId
private MatchKey id;
#Version
private Long version;
... generic match columns
}
and
#Entity
#DiscriminatorValue(OrganisationMatch.REFERENCE_KIND)
#ParametersAreNonnullByDefault
public class OrganisationMatch extends Match
{
static final String REFERENCE_KIND = "ORGANISATION";
#JoinColumn(name = "reference_id")
#OneToOne(fetch = LAZY, optional = false)
private Organisation organisation;
public OrganisationMatch()
{
setReferenceKind(MatchableEntityKind.valueOf(REFERENCE_KIND));
}
public OrganisationMatch(OrganisationId organisationId)
{
super(new MatchKey(organisationId));
setReferenceKind(MatchableEntityKind.valueOf(REFERENCE_KIND));
}
public Organisation getOrganisation()
{
return organisation;
}
}

Related

Vaadin flow Grid items duplicate rows

Vaadinversion: 14.4.1
spring-boot-starter-parent: 2.2.10RELEASE
I have two items in my grid. These two items looks like:
Kontakt{id=11657f9e-c4f4-414f-aab2-618252db9b06'vorname='test1'...
Kontakt{id=8da74f38-2072-4fb0-8c74-aede661f02b5'vorname='test'...
But the grid only displays only one items and so oft like the "itemslist.size()"
Also they react as "one row". So I can like on the first and both get selected.
These are my #Entity(s)
#Entity
#Table(name = "std_kunde")
#Data
public class Kunde extends Kontakt {
public Kunde() {
super();
}
#Override
public String toString() {
return super.toString();
}
}
#Entity
#Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
#Data
public abstract class Kontakt extends BasicEntity {
private String vorname;
private String name;
...
public Kontakt() {
super();
}
#Override
public String toString() {
return "Kontakt{" +
"id=" + getId() + '\'' +
"vorname='" + vorname + '\'' +
...
'}';
}
}
#Entity
#Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
#Data
public abstract class BasicEntity {
#Id
#GenericGenerator(name = "id_generator", strategy = "....KeyGenerator")
#GeneratedValue(generator = "id_generator")
#Column(length = 128)
private String id;
#CreationTimestamp
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "create_date")
private Date createDate;
#UpdateTimestamp
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "modify_date")
private Date modifyDate;
#OneToMany(cascade = CascadeType.ALL, mappedBy = "basicEntity")
private List<Anhang> anhangList;
#OneToMany(cascade = CascadeType.ALL, mappedBy = "basicEntity")
private List<Notiz> notizList;
public BasicEntity() {
anhangList = new ArrayList<>();
notizList = new ArrayList<>();
}
#Override
public int hashCode() {
return Objects.hash(id);
}
#Override
public boolean equals(Object o){
if(null == o)
return false;
if(!(o instanceof BasicEntity))
return false;
BasicEntity b = (BasicEntity) o;
return b.getId().equals(this.getId());
}
}
And also the Grid code
#Autowired
private KundeService kundeService;
private Grid<Kunde> g;
public Dashboard() {
g = new Grid<>(Kunde.class);
g.addColumn(Kunde::getVorname).setHeader("Vorname");
g.setSizeFull();
setSizeFull();
add(g);
}
I tested to build a Grid based upon an other entiy and it worked like it should. Its like the first time I have this behaivor but I dont know how actually to debug it...
EDIT 29.10.2020 ---------------------------------------------------------------
This is the #Entity (Notiz) which works like expected.
UI-Code
private Grid<Kunde> g;
private Grid<Notiz> n;
public Dashboard() {
g = new Grid<>(Kunde.class);
g.addColumn(Kunde::getId).setHeader("ID");
g.addColumn(Kunde::getVorname).setHeader("Vorname");
g.setSizeFull();
n = new Grid<>(Notiz.class);
n.addColumn(Notiz::getId).setHeader("ID");
n.addColumn(Notiz::getTitel).setHeader("Titel");
n.setSizeFull();
setSizeFull();
add(g,n);
}
#PostConstruct
private void loadValues(){
g.setItems(kundeService.findAll());
n.setItems(notizService.findAll());
}
#Entity
#Table(name = "ld_notiz")
#Data
public class Notiz extends BasicEntitySystemFeatures {
private String titel;
#Column(length = 5000) //TODO
private String content;
private boolean abgeschlossen = false;
#Enumerated(EnumType.STRING)
private NOTIZ_TYP notizTyp;
public enum NOTIZ_TYP {
NOTIZ,
ERINNERUNG
}
#ManyToOne
private BasicEntity basicEntity;
public Notiz() {
super();
}
}
#Entity
#Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
#Data
public abstract class BasicEntitySystemFeatures {
#Id
#GenericGenerator(name = "id_generator", strategy = "...KeyGenerator")
#GeneratedValue(generator = "id_generator")
#Column(length = 128)
private String id;
#CreationTimestamp
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "create_date")
private Date createDate;
#UpdateTimestamp
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "modify_date")
private Date modifyDate;
public BasicEntitySystemFeatures() {
}
#Override
public int hashCode() {
return Objects.hash(id);
}
#Override
public boolean equals(Object o){
if(null == o)
return false;
if(!(o instanceof BasicEntitySystemFeatures))
return false;
BasicEntitySystemFeatures b = (BasicEntitySystemFeatures) o;
return b.getId().equals(this.getId());
}

Hibernate issue - missing association in #JoinTable

I'm using Spring and Hibernate. I have following JPA mapping:
#Entity
#Inheritance(strategy = InheritanceType.SINGLE_TABLE)
#DiscriminatorColumn(name = "chg_type")
public abstract class EntitlementChange extends AbstractEntity<Long> {
protected static List<Argument<?>> copy(List<Argument<?>> arguments) {
return arguments.stream()
.map(Argument::getCopy)
.collect(toList());
}
protected EntitlementChange(List<Argument<?>> arguments) {
super();
this.arguments = copy(arguments);
}
#Id
#GeneratedValue(generator = SequenceOf.ENTITLEMENT_CHANGE_IDS)
#SequenceGenerator(name = SequenceOf.ENTITLEMENT_CHANGE_IDS, sequenceName = SequenceOf.ENTITLEMENT_CHANGE_IDS, allocationSize = 50)
private Long id;
#OneToMany(cascade = CascadeType.ALL)
#JoinTable
private List<Argument<?>> arguments;
}
And entity which inherits from EntitlementChange class.
#Entity
#DiscriminatorValue(EntitlementModification.DISCRIMINATOR)
public class EntitlementModification extends EntitlementChange {
public static final String DISCRIMINATOR = "modify";
public EntitlementModification(List<Argument<?> arguments) {
super(arguments);
}
}
The problem is that when I'm creating new EntitlementModification object with list of arguments and saving it to database using transaction:
#Transactional
public EntitlementChange createEntitlementChange(List<Argument<?>> arguments) {
EntitlementChange change = new EntitlementModification(arguments);
return entitlementChangeRepository.save(change);
}
I get EntitlementChange object with new ID which contain arguments list with assigned ID's too. When we look to the database, we can see that arguments entries are created, EntitlementChange entry is created, but association in joining table is not created. So when I'm getting EntitlementChange object using repository, arguments are null. Argument class:
#Entity
#DiscriminatorColumn(name = "arg_type", discriminatorType = DiscriminatorType.STRING)
#Inheritance(strategy = InheritanceType.SINGLE_TABLE)
#JsonTypeInfo(include = As.PROPERTY, property = "type", use = JsonTypeInfo.Id.NAME)
#JsonSubTypes({
#Type(value = LongStringArgument.class, name = LongStringArgument.DISCRIMINATOR),
#Type(value = StringArgument.class, name = StringArgument.DISCRIMINATOR),
#Type(value = BooleanArgument.class, name = BooleanArgument.DISCRIMINATOR),
#Type(value = SelectOneArgument.class, name = SelectOneArgument.DISCRIMINATOR),
#Type(value = MultiSelectArgument.class, name = MultiSelectArgument.DISCRIMINATOR),
#Type(value = IntegerArgument.class, name = IntegerArgument.DISCRIMINATOR)
})
public abstract class Argument<T> extends AbstractEntity<Long> {
#Id
#GeneratedValue(generator = SequenceOf.ARGUMENT_IDS)
#SequenceGenerator(name = SequenceOf.ARGUMENT_IDS, sequenceName = SequenceOf.ARGUMENT_IDS, allocationSize = 50)
private Long id;
private String name;
protected Argument() {
super();
}
public Argument(String name) {
super();
this.name = name;
}
#Override
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public abstract T getValue();
#JsonIgnore
public abstract Argument<T> getCopy();
#Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Argument))
return false;
Argument<?> argument = (Argument<?>) o;
return new EqualsBuilder()
.append(getName(), argument.getName())
.isEquals();
}
#Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(getName())
.toHashCode();
}
}
What could be a reason of this strange behaviour?

Foreign Key Problems with Hibernate (Bug?)

at our current project we are experiencing some difficulties. I recently changed some Hibernate Beans (our Article Bean and some underlying stuff) and I ran some tests and everything looked fine. Now my teammate is having exceptions with this message:
Foreign key (FK_09fd525ae6654c059394d22cc15:ARTBILDER [artikel_fk,servdat_fk])) must have same number of columns as the referenced primary key (ARTIKEL [AUTOIN_FIX])
The annotations are definitely correct. I had the same problem and decided to setup the project on my computer from scratch and the problems were gone. What can be the reason for these problems?
We are working on a legacy database and are only mapping our objects to the database and not generating the database with hibernate. And we are using HibernateSearch for full-text search (maybe this is related, because the first time this occured was after I added the HibernateSearch Annotations).
We are using a Firebird 2.5 instance.
EDIT:
here is the property the error is coming from:
The ID Class:
#Embeddable
public class ID implements Serializable {
private static final long serialVersionUID = 1810044174631580834L;
private Long autoin;
private Integer serverId;
public ID() {
}
public ID(Long autoin, Integer serverId) {
this.autoin = autoin;
this.serverId = serverId;
}
#Column(name = "autoin_fix")
public Long getAutoin() {
return this.autoin;
}
#Column(name = "servdat_fk")
public Integer getServerId() {
return this.serverId;
}
public void setAutoin(Long autoin) {
this.autoin = autoin;
}
public void setServerId(Integer serverId) {
this.serverId = serverId;
}
#Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((this.autoin == null) ? 0 : this.autoin.hashCode());
result = prime * result
+ ((this.serverId == null) ? 0 : this.serverId.hashCode());
return result;
}
#Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
ID other = (ID) obj;
if (this.autoin == null) {
if (other.autoin != null) {
return false;
}
} else if (!this.autoin.equals(other.autoin)) {
return false;
}
if (this.serverId == null) {
if (other.serverId != null) {
return false;
}
} else if (!this.serverId.equals(other.serverId)) {
return false;
}
return true;
}
#Override
public String toString() {
return new StringBuilder().append("ID [").append(this.autoin)
.append("_").append(this.serverId).append("]").toString();
}
}
The Article class:
#Indexed
#Entity
#Table(name = "ARTIKEL")
public class Article {
private ID id;
private List<Picture> pictures;
...
#DocumentId
#EmbeddedId
#FieldBridge(impl = IDBridge.class)
public ID getId() {
return id;
}
#OneToMany
#JoinColumns({
#JoinColumn(name = "artikel_fk", referencedColumnName = "autoin_fix"),
#JoinColumn(name = "servdat_fk", referencedColumnName = "servdat_fk") })
#IndexedEmbedded
public List<Picture> getPictures() {
return pictures;
}
}
The Picture class:
#Entity
#Table(name = "ARTBILDER")
public class Picture extends BasePicture {
...
protected ID id;
#EmbeddedId
#FieldBridge(impl = IDBridge.class)
#Field(store = Store.YES, index = Index.YES)
public ID getId() {
return id;
}
...
}
EDIT2: I may have a clue where this comes from, please standby.
EDIT3: Nope, not the error.
EDIT4: Here is the DDL:
CREATE TABLE ARTIKEL
(
AUTOIN_FIX NUM10_0 DEFAULT 0,
SERVDAT_FK NUM10_0 DEFAULT 0,
...
PRIMARY KEY (AUTOIN_FIX,SERVDAT_FK)
);
CREATE TABLE ARTBILDER
(
AUTOIN_FIX NUM10_0 DEFAULT 0,
ARTIKEL_FK NUM10_0 DEFAULT 0,
SERVDAT_FK NUM10_0 DEFAULT 0,
...
PRIMARY KEY (AUTOIN_FIX,SERVDAT_FK)
);
Here is full link and description
OneToMany(fetch = FetchType.LAZY)
#JoinTable(name = "DATA_VALUE", joinColumns = {
#JoinColumn(name = "DATA_ID"),
}, inverseJoinColumns = {
#JoinColumn(name = "COLUMN_NM")
})
List<DataValue> dataValueList;
OR more Descriptive
#Entity
public class Parent implements Serializable {
#Id
public ParentPk id;
public int age;
#OneToMany(cascade=CascadeType.ALL)
#JoinColumns ({
#JoinColumn(name="parentCivility", referencedColumnName = "isMale"),
#JoinColumn(name="parentLastName", referencedColumnName = "lastName"),
#JoinColumn(name="parentFirstName", referencedColumnName = "firstName")
})
public Set<Child> children; //unidirectional
...
}

Composite Foreign Key Issue while using Inheritance in JPA

I have a JPA Entity StatsEntity which has a composite primary key that is also as foreign key to another Entity Roster. This is setup as a #OneToOne relationship using #JoinColumns({#JoinColumn...}) annotations.
StatsEntity extends another entity CoreStatsEntity which is setup as #MappedSuperClass where as RosterEntity extends another entity CoreRoster using SINGLE_TABLE inheritance strategy.
#Entity
#Table(name = "Stats")
#IdClass(value = StatsEntity.Key.class)
public class StatsEntity extends CoreStatsEntity implements
Stats {
#Id
private Integer competitionId;
#Id
private Integer playerId;
#Id
private Integer teamId;
#OneToOne
#JoinColumns({
#JoinColumn(name = "competitionId", referencedColumnName = "competitionId", insertable = false, updatable=false),
#JoinColumn(name = "playerId", referencedColumnName = "personId", insertable = false, updatable=false),
#JoinColumn(name = "teamId", referencedColumnName = "teamId", insertable = false, updatable=false) })
private RosterEntity roster;
....
}
StatsEntity.Key
#Embeddable
public static class Key implements Serializable {
private static final long serialVersionUID = -7349082038890396790L;
#Column(name = "competitionId", insertable = false, updatable = false)
private Integer competitionId;
#Column(name = "playerId", insertable = false, updatable = false)
private Integer playerId;
#Column(name = "teamId", insertable = false, updatable = false)
private Integer teamId;
public Key() {
super();
}
public Key(int competitionId, int playerId, int teamId) {
this.competitionId = Integer.valueOf(competitionId);
this.playerId = Integer.valueOf(playerId);
this.teamId = Integer.valueOf(teamId);
}
public int getTeamId() {
return teamId.intValue();
}
public void setTeamId(int teamId) {
this.teamId = Integer.valueOf(teamId);
}
public int getPlayerId() {
return playerId.intValue();
}
public void setPlayerId(int playerId) {
this.playerId = Integer.valueOf(playerId);
}
public int getCompetitionId() {
return competitionId.intValue();
}
public void setCompetitionId(int CompetitionId) {
this.competitionId = Integer.valueOf(CompetitionId);
}
/*
* (non-Javadoc)
*
* #see java.lang.Object#equals(java.lang.Object)
*/
#Override
public boolean equals(Object object) {
if (object == this) {
return true;
}
if (!(object instanceof Key)) {
return false;
}
Key other = (Key) object;
return Utils.equals(other.getTeamId(), this.getTeamId())
&& Utils.equals(other.getPlayerId(), this.getPlayerId())
&& Utils.equals(other.getCompetitionId(),
this.getCompetitionId());
}
/*
* (non-Javadoc)
*
* #see java.lang.Object#hashCode()
*/
#Override
public int hashCode() {
return Utils.hashCode(this.teamId, this.playerId,
this.competitionId);
}
/*
* (non-Javadoc)
*
* #see java.lang.Object#toString()
*/
#Override
public String toString() {
return Utils.toString("CompetitionPlayerStatsEntity.Key",
this.teamId, this.playerId, this.competitionId);
}
}
CoreStatsEntity.java
#MappedSuperclass
public abstract class CoreStatsEntity
{}
RosterEntity
#Entity
#DiscriminatorValue("20")
public class RosterEntity extends
CoreRosterEntity {
//.... attributes, getters, setters
}
CoreRosterEntity.java
#Entity
#DiscriminatorValue("0")
#Table(name="Roster")
#IdClass(CoreRoster.Key.class)
#Inheritance(strategy=InheritanceType.SINGLE_TABLE)
#DiscriminatorColumn(name="discriminator", discriminatorType=DiscriminatorType.INTEGER)
public class CoreRosterEntity {
private static final long serialVersionUID = 1521639115446682871L;
#Id
private Integer competitionId;
#Id
private Integer teamId;
#Id
private Integer playerId;
//.. getters, setters and other attributes
}
CoreRoster.Key.class inside CoreRoster.java
#Embeddable
public static class Key implements Serializable {
private static final long serialVersionUID = 2L;
#Column(name="competitionId", nullable=false)
private Integer competitionId;
#Column(name="teamId", nullable=false)
private Integer teamId;
#Column(name="personId", nullable=false)
private Integer playerId;
public Key() {
super();
}
public Key(int competitionId, int teamId, int playerId) {
this.competitionId = Integer.valueOf(competitionId);
this.teamId = Integer.valueOf(teamId);
this.playerId = Integer.valueOf(playerId);
}
public int getPlayerId() {
return playerId.intValue();
}
public void setPlayerId(int playerId) {
this.playerId = Integer.valueOf(playerId);
}
public int getTeamId() {
return teamId.intValue();
}
public void setTeamId(int teamId) {
this.teamId = Integer.valueOf(teamId);
}
public int getCompetitionId() {
return this.competitionId.intValue();
}
public void setCompetitionId(int competitionId) {
this.competitionId = Integer.valueOf(competitionId);
}
/*
* (non-Javadoc)
* #see java.lang.Object#equals(java.lang.Object)
*/
#Override
public boolean equals(Object object) {
if (object == this) { return true; }
if (!(object instanceof Key)) { return false; }
Key other = (Key) object;
return Utils.equals(other.getCompetitionId(), this.getCompetitionId()) &&
Utils.equals(other.getTeamId(), this.getTeamId()) &&
Utils.equals(other.getPlayerId(), this.getPlayerId());
}
/*
* (non-Javadoc)
* #see java.lang.Object#hashCode()
*/
#Override
public int hashCode() {
return Utils.hashCode(this.competitionId, this.teamId,
this.playerId);
}
/*
* (non-Javadoc)
* #see java.lang.Object#toString()
*/
#Override
public String toString() {
return Utils.toString("CoreRoster.Key",
this.competitionId, this.teamId,
this.playerId);
}
}
When I persist StatsEntity, it gets persisted. But when I try to find it using the primary key it gives me an error:
StatsEntity playerStats = new StatsEntity();
//set all values
this.persist(playerStats);
entityManager.find(StatsEntity.class, playerStats.getId()); //getId returns the composite primary key
java.lang.IllegalArgumentException: Provided id of the wrong type for class com.sports.RosterEntity. Expected: class com.sports.CoreRoster$Key, got class com.espn.sports.StatsEntity$Key
My first question here is, is the #OneToOne mapping I have given correct or not?
If it is correct then why this error appears when I try to find the entity using primarykey.
You haven't posted full source code, especially of your primary key class, but you've mapped foreign key as read-only, which is required when single column is mapped more than once.
I see however that you id columns are exactly the same 3 columns that are foreign key to RosterEntity, rights? In that case this RosterEntity should be your ID, which would simplify your design.
What is the return type of your getId() method? The problem is propably with definition or usage of IdClass.

Hibernate #id composite

I am modeling a database.
There is TRIPLE which contains three CONCEPT. So the primary key of the class TRIPLE is three uri all together. (One concept could be in different TRIPLE).
Also TRIPLE is related with another class, ANNOTATION, and here is the question, how can triple_id be identified?? But first of all, if building this Id composite is correct.
To model that:
Concept.java
#Entity
#Table(name = "concept")
public class Concept implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private String id;
private List<TripleDBModel> triples;
#ManyToMany(
cascade={CascadeType.ALL},
fetch=FetchType.LAZY,
mappedBy = "concepts"
)
public List<TripleDBModel> getTriples() {
return triples;
}
public void setTriples(List<TripleDBModel> triples) {
this.triples = triples;
}
ConceptPk.java
#Embeddable
public class ConceptPk implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private String uri;
public ConceptPk(String uri, String label){
this.uri = uri;
}
public ConceptPk(){
super();
}
#Id
#Column(name = "uri", length = 100, unique = true, nullable = false)
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
}
Triple.java
#Entity
#IdClass(ConceptPk.class)
#Table(name = "triple")
public class TripleDBModel {
protected List<Annotation> annotations;
protected String conceptUriSubject;
protected String conceptUriObject;
protected String conceptUriPredicate;
#ManyToMany(
cascade={CascadeType.ALL},
fetch=FetchType.LAZY
)
#JoinTable(name = "triple_has_concept",
joinColumns=#JoinColumn(name="uri"),
inverseJoinColumns=#JoinColumn(name="triple_id")) //What shoul I write here???
public List<Annotation> getAnnotations() {
return annotations;
}
public void setAnnotations(List<Annotation> annotations) {
this.annotations = annotations;
}
#Id public String getConceptUriSubject() {
return conceptUriSubject;
}
public void setConceptUriSubject(String conceptUriSubject) {
this.conceptUriSubject = conceptUriSubject;
}
#Id public String getConceptUriObject() {
return conceptUriObject;
}
public void setConceptUriObject(String conceptUriObject) {
this.conceptUriObject = conceptUriObject;
}
#Id public String getConceptUriPredicate() {
return conceptUriPredicate;
}
public void setConceptUriPredicate(String conceptUriPredicate) {
this.conceptUriPredicate = conceptUriPredicate;
}
}
Thanks in advance!!
You could use an Id class like this:
class TripleId implements Serializable {
#Column(...)
private String conceptUriSubject;
#Column(...)
private String conceptUriObject;
}
And use it in Triple:
#Entity
#Table(name = "triple")
public class TripleDBModel {
#EmbeddedId
private TripleId id;
...
}
Also note that you can provide multiple join columns:
inverseJoinColumns= {#JoinColumn(name="subjectUri"), #JoinColumn(name="objectUri"), ... }

Categories

Resources