I have a couple of tables with relation as in the image below
I created hibernate data model as follows
#Entity
#Table(name = "SUBJECT")
public class Subject {
#Column(name = "NAME")
private String name;
#Column(name = "ADDRESS")
private String address;
#Column(name = "CLIENT_ID")
private String clientId;
#OneToMany(mappedBy = "subject", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<SSI> SSIs;
// getters and setters
...
}
#Entity
#Table(name = "SUBJECT_IDENTIFIER")
public class SubjectIdentifier {
#Column(name = "VALUE")
private String value;
#Column(name = "AUTHORITY")
private String authority;
#Column(name = "TYPE")
private String type;
#ManyToOne
#JoinColumns({
#JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID", insertable = true,
updatable = true,
#JoinColumn(name = "CLIENT_ID", referencedColumnName = "CLIENT_ID", insertable =
true, updatable = true)
})
private Subject subject;
// getters and setters
...
}
#Entity
#Table(name = "SSI")
public class SSI {
#ManyToOne
#JoinColumns({
#JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID", insertable = true,
updatable = true),
#JoinColumn(name = "CLIENT_ID", referencedColumnName = "CLIENT_ID", insertable =
true, updatable = true)
})
private Subject subject;
#OneToOne(cascade = CascadeType.ALL)
#JoinColumns({
#JoinColumn(name = "SUBJECT_IDENTIFIER_ID", referencedColumnName = "ID", insertable = true,
updatable = true),
#JoinColumn(name = "CLIENT_ID", referencedColumnName = "CLIENT_ID", insertable =
true, updatable = true)
})
private SubjectIdentifier subjectIdentifier;
// getters and setters
...
}
I intend to create the entities as follows
...
Subject s = new Subject();
//.. initialization of s goes here
SubjectIdentifier si = new SubjectIdentifier();
//.. initialization of si goes here
SSI ssi = new SSI();
ssi.setSubject(s);
ssi.setSubjectIdentifier(si);
s.setSSI(ssi);
...
emProvider.get().persist(s);
When I run this, I get following error
org.hibernate.MappingException: Repeated column in mapping for entity: *.SSI column: CLIENT_ID (should be mapped with insert="false" update="false")
If I set insert="false" update="false" for CLIENT_ID, it would error again about mixing of insert & update with other column in the #Joincolumns
If I set insert="false" update="false" for all the #JoinColumns then it will not persist the objects.
How to really handle this kind of entity creation?
That's not so easy. If you want that, you have to introduce another attribute for storing the client id and maintain this denormalization:
#Entity
#Table(name = "SSI")
public class SSI {
#Column(name = "CLIENT_ID")
private String clientId;
#Column(name = "SUBJECT_ID")
private String subjectId;
#Column(name = "SUBJECT_IDENTIFIER_ID")
private String subjectIdentifierId;
#ManyToOne
#JoinColumns({
#JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID", insertable = false,
updatable = false),
#JoinColumn(name = "CLIENT_ID", referencedColumnName = "CLIENT_ID", insertable =
false, updatable = false)
})
private Subject subject;
#OneToOne(cascade = CascadeType.ALL)
#JoinColumns({
#JoinColumn(name = "SUBJECT_IDENTIFIER_ID", referencedColumnName = "ID", insertable = false,
updatable = false),
#JoinColumn(name = "CLIENT_ID", referencedColumnName = "CLIENT_ID", insertable =
false, updatable = false)
})
private SubjectIdentifier subjectIdentifier;
// getters and setters
...
}
Related
I'm trying to save a complex entity with Hibernate where we have multiple entities with composite keys.
When I try tosave it seems that Hibernate it is not retrieving correctly the values from some columns on child entities which have composite key hence postgre is returning a not-null violation error.
#Entity
#Table(name = "activities", schema = "ptw")
#Data
#TypeDefs({
#TypeDef(name = "jsonb", typeClass = JsonBinaryType.class),
#TypeDef(name = "pg-id-uuid", typeClass = PostgresIdUUIDType.class)
})
public class Activity extends AuditAtBy implements Serializable {
#EmbeddedId
private CommonId commonId;
#MapsId("siteId")
#ManyToOne
#OnDelete(action = OnDeleteAction.CASCADE)
#Type(type = "pg-id-uuid")
#JoinColumn(name="site_id",referencedColumnName = "id", columnDefinition = "uuid", updatable = false)
private Site site;
#ManyToOne()
#JoinColumnsOrFormulas(value = {
#JoinColumnOrFormula(formula = #JoinFormula(value="location_id", referencedColumnName = "id")),
#JoinColumnOrFormula(formula = #JoinFormula(value="site_id", referencedColumnName = "site_id"))})
#Type(type = "pg-id-uuid")
#OnDelete(action = OnDeleteAction.CASCADE)
private Location location;
#ManyToOne
#JoinColumns({
#JoinColumn(name = "job_pack_id", referencedColumnName = "id", columnDefinition = "uuid", insertable = false, updatable = false),
#JoinColumn( name = "site_id", referencedColumnName="site_id", columnDefinition = "uuid", insertable = false, updatable = false)
})
#Type(type = "pg-id-uuid")
#OnDelete(action = OnDeleteAction.CASCADE)
private JobPack jobPack;
#Column(name = "permit_number", nullable = false, length = 10)
private String permitNumber;
#Column(name = "order_number", nullable = false)
private short orderNumber;
#Column(name = "location_name", length = 200)
private String locationName;
**#ManyToOne
#JoinColumns({
#JoinColumn(name = "state_id", referencedColumnName="id", columnDefinition = "uuid", insertable = false, updatable = false),
#JoinColumn(name = "site_id", referencedColumnName="site_id", columnDefinition = "uuid", insertable = false, updatable = false)
})
#Type(type = "pg-id-uuid")
private ActivityState state;**
#ManyToOne
#JoinColumns({
#JoinColumn(name = "activity_type_id", referencedColumnName="id", columnDefinition = "uuid", insertable = false, updatable = false),
#JoinColumn(name = "site_id", referencedColumnName="site_id", columnDefinition = "uuid", insertable = false, updatable = false)
})
#Type(type = "pg-id-uuid")
#OnDelete(action = OnDeleteAction.CASCADE)
private ActivityType activityType;
public UUID getId(){
return this.getCommonId().getId();
}
public void setId(UUID id){
if (this.getCommonId() == null) {
this.setCommonId(new CommonId());
}
this.getCommonId().setId(id);
}
public void setSite(Site site){
this.site = site;
if (this.getCommonId() == null) {
this.setCommonId(new CommonId());
}
this.getCommonId().setSiteId(site.getId());
}
}
The setId/getId/ setSite are overriden in order to update the entity when using a mapper to convert from the DTO to the Entity
The ActivityState is as follows:
#Entity
#Table(name = "activity_states", schema = "ptw")
#Data
#TypeDefs({
#TypeDef(name = "pg-id-uuid", typeClass = PostgresIdUUIDType.class)
})
public class ActivityState extends AuditAtBy implements Serializable {
#EmbeddedId
private CommonId commonId;
#MapsId("siteId")
#ManyToOne
#OnDelete(action = OnDeleteAction.CASCADE)
private Site site;
#Column(nullable = false, length = 50)
private String name;
#Column(name = "icon_id", nullable = false)
private short iconId;
#Column(name = "is_initial", nullable = false)
private boolean isInitial;
#Column(name = "order_number", nullable = false)
private short orderNumber;
public UUID getId(){
return this.getCommonId().getId();
}
public void setId(UUID id){
if (this.getCommonId() == null) {
this.setCommonId(new CommonId());
}
this.getCommonId().setId(id);
}
public void setSite(Site site){
this.site = site;
if (this.getCommonId() == null) {
this.setCommonId(new CommonId());
}
this.getCommonId().setSiteId(site.getId());
}
}
When I try to save the exception is:
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "state_id" violates not-null constraint
Detail: Failing row contains (c821ff72-de93-4c03-abf5-e18347c29955, null, 0, 5081790f-19ed-44e0-be17-94f94aed878b, null, null, test, test, null, 1, 1, f, N/A, 1, null, null, null, null, null, null, null, null, null, null, null, f, {"title": "test", "DateTable": {"timeTo": "", "timeFrom": "", "v..., 2021-12-09 13:46:02.829157+01, 2021-12-09 13:46:02.829157+01, 7b0702c7-9f11-4a92-bfdf-7f98eb8ac94d, 7b0702c7-9f11-4a92-bfdf-7f98eb8ac94d, null, null, f).
I have no idea about how to solve although I have tried multiple things changing the mappings and relationships.
I know that composites keys are not the best approach but we have a multitenancy system where the best approach to keep data isolated was this one.
The answer was basically the first answer to this post: Should Hibernate be able to handle overlapping foreign keys?
Basically changing the mapping to be with the actual column as column and the one repeated in other entities as formula it is working now:
#JoinColumnsOrFormulas(value = {
#JoinColumnOrFormula(column = #JoinColumn(name="state_id", referencedColumnName = "id")),
#JoinColumnOrFormula(formula = #JoinFormula(value="site_id", referencedColumnName = "site_id")) })
I have 4 entities: workflowEntity, PhaseEntity, RoundEntity and BlockEntity.
The structure is supposed to be following:
Workflow:
Phase:
Round(optional):
Block
or if there are no rounds, since round_id in workflow_binding table is nullable;
Workflow:
Phase:
Block
I need workflowEntity, when bound with Phase, Block or Round entities, to hold the information of those entitites, but those other entites should not contain any information of their "structural children". e.g I request getAllPhases(), then those Phases that get returned, should not contain information of any Blocks nor Rounds, because unless phases are bound within workflow, they are not tied with Blocks nor Rounds in any way. They can only be tied with Blocks and Rounds in bound workflowEntity.
I have tried to use #JoinTable (commented out examples in workflowEntity, PhaseEntity and RoundEntity), but this returned too much data, that wasnt bound to requested workflow.
Basically I need WorkflowEntity to contain fields such as:
private Map<PhaseEntity, Map<RoundEntity, Set<BlockEntity>>> phaseRoundEntityMap;
private Map<PhaseEntity, Set<BlockEntity>> phaseBlockEntityMap;
#Entity
#Data
#Table(name="workflow")
public class WorkflowEntity {
#Id
#GeneratedValue(generator = "UUID")
#GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
#Column(name = "id")
private UUID id;
#NotBlank
#Size(min = 1, max = 255)
#Column(name= "name")
private String name;
#Column(name="days")
private Integer days;
/*
#OneToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE}, fetch = FetchType.EAGER)
#JoinTable(name = "workflow_binding",
joinColumns = {#JoinColumn(name = "workflow_id")},
inverseJoinColumns = {#JoinColumn(name = "workflow_phase_id")})
private Set<PhaseEntity> phases;*/
//I need to map these somehow
private Map<PhaseEntity, Map<RoundEntity, Set<BlockEntity>>> phaseRoundEntityMap;
private Map<PhaseEntity, Set<BlockEntity>> phaseBlockEntityMap;
}
#Entity
#Data
#Table(name="workflow_phase")
#NoDuplicatePhases
public class PhaseEntity {
#Id
#GeneratedValue(generator = "UUID")
#GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
#Column(name = "id", updatable = false, nullable = false)
private UUID id;
#NotBlank
#Size(min = 1, max = 255)
private String name;
#Size(max = 1500)
private String description;
private Integer sequenceNumber;
// Phase shouldnt actually contain any information about blocks nor rounds, unless bound with a workflow.
/* Commented out, because includes blocks and rounds not bound to requested workflow
#OneToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE}, fetch = FetchType.EAGER)
#JoinTable(name = "workflow_binding",
joinColumns = {#JoinColumn(name = "workflow_phase_id")},
inverseJoinColumns = {#JoinColumn(name = "workflow_block_id")})
private Set<BlockEntity> blocks;
#OneToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE}, fetch = FetchType.EAGER)
#JoinTable(name = "workflow_binding",
joinColumns = {#JoinColumn(name = "workflow_phase_id")},
inverseJoinColumns = {#JoinColumn(name = "workflow_round_id")})
private Set<RoundEntity> rounds;*/
}
#Entity
#Data
#Table(name="workflow_round")
#NoDuplicateRounds
public class RoundEntity {
#Id
#GeneratedValue(generator = "UUID")
#GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
#Column(name = "id", updatable = false, nullable = false)
private UUID id;
#NotBlank
#Size(min = 1, max = 255)
private String name;
private Integer sequenceNumber;
/*Commented out, because includes blocks not bound to requested workflow
#OneToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE}, fetch = FetchType.EAGER)
#JoinTable(name = "workflow_binding",
joinColumns = {#JoinColumn(name = "workflow_round_id", nullable = false, updatable = false)},
inverseJoinColumns = {#JoinColumn(name = "workflow_block_id", nullable = false, updatable = false)})
private Set<BlockEntity> blocks;*/
}
#Entity
#Data
#Table(name = "workflow_block")
public class BlockEntity {
#Id
#GeneratedValue(generator = "UUID")
#GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
#Column(name = "id", updatable = false, nullable = false)
private UUID id;
#NotBlank
#Size(min = 1, max = 255)
private String name;
#Size(max = 1500)
private String description;
#OneToMany(cascade = {CascadeType.DETACH, CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.MERGE}, orphanRemoval = true, fetch = FetchType.EAGER)
#JoinTable(name = "workflow_assignment_block",
joinColumns = {#JoinColumn(name = "workflow_block_id", nullable = false, updatable = false)},
inverseJoinColumns = {#JoinColumn(name = "workflow_assignment_id")})
private Set<AssignmentEntity> assignments;
private Integer sequenceNumber;
#Column(name = "due_date_day")
private Integer dueDate;
}
Why not create an entity WorkflowBinding?
#Entity
#Table(name = "workflow_binding")
public class WorkflowBinding {
#EmbeddedId
private WorkflowBindingId id;
#ManyToOne(fetch = LAZY)
#JoinColumn(name = "block_id", insertable = false, updatable = false)
private BlockEntity block;
#ManyToOne(fetch = LAZY)
#JoinColumn(name = "round_id", insertable = false, updatable = false)
private RoundEntity round;
#ManyToOne(fetch = LAZY)
#JoinColumn(name = "phase_id", insertable = false, updatable = false)
private PhaseEntity phase;
#ManyToOne(fetch = LAZY)
#JoinColumn(name = "workflow_id", insertable = false, updatable = false)
private WorkflowEntity workflow;
}
#Embeddable
public class WorkflowBindingId {
private UUID blockId;
private UUID roundId;
private UUID phaseId;
private UUID workflowId;
}
On the inverse side you can then do mappings like this:
public class BlockEntity {
#OneToMany(mappedBy = "block")
private Set<WorkflowBinding> bindings;
....
}
I have manyToMany relationship mapping and couldn't get it to work. I have read many posts and articles and couldn't figure this one out. If anyone has some idea please share.
I have tried to simplify diagram and code as much.
My database is designed like this:
My entities look like this (at least final attempt before asking):
Client:
#Entity
#Table(name = "client")
public class Client implements Serializable {
#Id
#Column(name = "client_id")
private int id;
... other fields
}
Project:
#Entity
#Table(name = "project")
public class Project implements Serializable {
#EmbeddedId
private ProjectId id;
... other fields
#Embeddable
class ProjectId implements Serializable {
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "client_id", insertable = false, updatable = false)
private Client client;
#Column(name = "project_id")
private int projectId;
}
}
User:
#Entity
#Table(name = "user")
public class User implements Serializable {
#EmbeddedId
private UserId id;
... other fields
#Embeddable
class UserId implements Serializable {
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "client_id", insertable = false, updatable = false)
private Client client;
#Column(name = "user_id")
private int userId;
}
}
ProjectUser:
#Entity
#Table(name = "project_user")
public class ProjectUser implements Serializable {
#EmbeddedId
private ProjectUserId id;
... other fields
#Embeddable
class ProjectUserId implements Serializable {
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "client_id", insertable = false, updatable = false)
private Client client;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumns({
#JoinColumn(name = "client_id", referencedColumnName = "client_id", insertable = false, updatable = false),
#JoinColumn(name = "project_id", referencedColumnName = "project_id", insertable = false, updatable = false) })
private Project project;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumns({
#JoinColumn(name = "client_id", referencedColumnName = "client_id", insertable = false, updatable = false),
#JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false) })
private User user;
}
}
Before adding ProjectUser entity everything is working fine.
Now when I'm starting server it says:
Repeated column in mapping for entity: ProjectUser column: client_id
(should be mapped with insert=\"false\" update=\"false\")"}}
So, the question is how do I make this work?
EDIT:
Java application will be mostly REST services providing data. Database design is as is. It has logical sense and most of the business logic will be in database. We have people with very good DB knowledge working on this and it would not make much sense changing database design because of JPA/Hibernate limitations.
The code below will let hibernate create a structure for your entities:
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "client_id", insertable = false, updatable = false)
private Client client;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumns({
#JoinColumn(name = "project_client_id", referencedColumnName = "client_id", insertable = false, updatable = false),
#JoinColumn(name = "project_id", referencedColumnName = "project_id", insertable = false, updatable = false) })
private Project project;
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumns({
#JoinColumn(name = "user_client_id", referencedColumnName = "client_id", insertable = false, updatable = false),
#JoinColumn(name = "user_id", referencedColumnName = "user_id", insertable = false, updatable = false) })
private User user;
But to make a scheme as on the picture in your question, get rid of all these EmbeddedId. Use simple ids and add validation in your code, if you want project and user inside your ProjectUser have the same client_id.
Need criteria join query for a composite primary key.
Entities:
ArtWork
#Entity
#Table(name = "artwork")
public class ArtWork implements io.malevich.web.entity.Entity {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Id
#Column(name = "language", columnDefinition = "CHAR(2)")
private String language;
#Column(name = "art_name", nullable = false)
private String artName;
#Column(name = "creation_date", nullable = false)
private Date creationDate;
#Column(name = "edition_flag", nullable = false, columnDefinition = "tinyint(1)")
private boolean editionFlag;
#Column(name = "replica_flag", nullable = false, columnDefinition = "tinyint(1)")
private boolean replicaFlag;
#Column(name = "number_of_editions")
private Long numberOfEditions;
#Column(name = "original_id")
private Long originalId;
#ManyToOne
#JoinColumns({
#JoinColumn(
name = "category_id",
referencedColumnName = "id", insertable = false, updatable = false),
#JoinColumn(
name = "language",
referencedColumnName = "language", insertable = false, updatable = false)
})
private Category category;
#ManyToOne
#JoinColumns({
#JoinColumn(
name = "gallery_id",
referencedColumnName = "id", insertable = false, updatable = false),
#JoinColumn(
name = "language",
referencedColumnName = "language", insertable = false, updatable = false)
})
private Gallery gallery;
#ManyToOne
private Specialization specialization;
#ManyToOne
#JoinColumns({
#JoinColumn(
name = "author_id",
referencedColumnName = "id", insertable = false, updatable = false),
#JoinColumn(
name = "language",
referencedColumnName = "language", insertable = false, updatable = false)
})
private Author author;
#Column
private String description;
#Column
private Double price;
//getter setter
}
User:
#javax.persistence.Entity
#Table(name = "user")
public class User implements Entity, UserDetails {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(unique = true, length = 255, nullable = false)
private String name;
#Column(length = 255, nullable = false)
private String password;
#ElementCollection(fetch = FetchType.EAGER)
private Set<Role> roles = new HashSet<>();
#Column(name = "user_type_id")
private Long userTypeId;
#ManyToOne
#JoinColumn(name = "person_id", referencedColumnName = "id")
private Person person;
#ManyToOne
#JoinColumn(name = "organization_id", referencedColumnName = "id")
private Organization organization;
#ManyToOne
#JoinColumn(name = "file_id", referencedColumnName = "id")
private File file;
#Column(name = "activity_flag")
private boolean activityFlag;
//gettter and setter
}
Account States
#javax.persistence.Entity
#Table(name = "account_states")
public class AccountStates implements Entity {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
#Column(insertable = false, updatable = false)
private String language;
#ManyToOne
#JoinColumns({ #JoinColumn(name = "artwork_id", referencedColumnName = "id"),
#JoinColumn(name = "language", referencedColumnName = "language") })
private ArtWork artwork;
#ManyToOne
#JoinColumn(name = "art_owner_id", referencedColumnName = "id")
private User artOwner;
#Column(name = "quantity")
private Long quantity;
#Temporal(TemporalType.DATE)
#Column(name = "buy_date")
private Date buyDate;
}
Account State Dao:
public class JpaAccountStatesDao extends JpaDao
implements AccountStatesDao {
public JpaAccountStatesDao() {
super(AccountStates.class);
}
#Override
public AccountStates find(Long artOwnerId, Long artworkId, String language) {
final CriteriaBuilder builder = this.getEntityManager().getCriteriaBuilder();
final CriteriaQuery<AccountStates> criteriaQuery = builder.createQuery(AccountStates.class);
Root<AccountStates> root = criteriaQuery.from(AccountStates.class);
Predicate p1 = builder.and(builder.equal(root.get("artwork"), artworkId),
builder.equal(root.get("artwork"), language), builder.equal(root.get("artOwner"), artOwnerId));
criteriaQuery.where(p1);
TypedQuery<AccountStates> typedQuery = this.getEntityManager().createQuery(criteriaQuery);
return typedQuery.getSingleResult();
}
}
I want to find Account States where artOwner id = 1 and language = en and artwork id = 1.
Can anyone suggest proper query for the same?
I found a solution for the same, I tried to pass a whole object instead of object id.
So final query is:
#Override
public AccountStates find(User artOwner, Artwork artwork) {
final CriteriaBuilder builder = this.getEntityManager().getCriteriaBuilder();
final CriteriaQuery<AccountStates> criteriaQuery = builder.createQuery(AccountStates.class);
Root<AccountStates> root = criteriaQuery.from(AccountStates.class);
Predicate p1 = builder.and(builder.equal(root.get("artwork"), artwork),
builder.equal(root.get("artOwner"), artOwner));
criteriaQuery.where(p1);
TypedQuery<AccountStates> typedQuery = this.getEntityManager().createQuery(criteriaQuery);
return typedQuery.getSingleResult();
}
}
Now, It works successfully... thanks
I have a following example I want to create a lazy #ManyToOne relation between Car and CarAchievement tables using multiple join columns (example of class below)
#Entity
#Table(name = "CAR")
public class Car implements Serializable {
#Id
#GenericGenerator(name = "SEQ_CAR", strategy = "sequence",
parameters = {
#org.hibernate.annotations.Parameter(
name = "sequence",
value = "SEQ_CAR"
)
}
)
#GeneratedValue(generator = "SEQ_CAR")
#Column(name = "ID")
private Integer id;
#ManyToOne(fetch = FetchType.LAZY)
#NotFound(action = NotFoundAction.IGNORE)
#JoinColumns({
#JoinColumn(name = "region", referencedColumnName = "region", updatable = false, insertable = false),
#JoinColumn(name = "model", referencedColumnName = "model", updatable = false, insertable = false),
#JoinColumn(name = "year", referencedColumnName = "type", updatable = false, insertable = false),
#JoinColumn(name = "type", referencedColumnName = "year", updatable = false, insertable = false)
})
#JsonIgnore
private CarAchievement carAchievement;
}
This relation works fine but it seems not to be a LazyFetch, every query for a CAR seems to be fetching CarAchievement automatically even when its not specified to fetch this relation
Hibernate version: 4.3.10.Final