Questions tagged [embeddable]

@Embeddable is an annotation used in Java to suggest that a class is stored as an intrinsic part of an owning entity and share the identity of the entity. It is a part of JPA implementations.

@Embeddable is an annotation used in to suggest that a class is stored as an intrinsic part of an owning entity and share the identity of the entity. It is a part of implementations/frameworks such as . This annotation will suggest to the framework that the class is a part of another entity and will treat any mapped attribute within the class as a mapped attribute of the containing entity.

It corresponds to other annotations which may be used by the owning Entity such as @Embedded and @Entity.

Java EE Documentation

SO question covering the basics of Embeddable

141 questions
1
vote
1 answer

Embeddable entity with @OneToOne attribute

I recently had the need to map a one-to-one entity from an embbeded entity: @Entity public class A { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Embedded private B b; //getters and…
tiagomistral
  • 143
  • 8
1
vote
0 answers

JPA/Hibernate: Merge an attribute of Composite Key creates another row instead of updating existing

Following is composite key: @Embeddable public class EmployeePK implements Serializable { private static final long serialVersionUID = 1L; @Basic(optional = false) @Column(name = "EMPLOYEEID") private String employeeId; …
fatherazrael
  • 5,511
  • 16
  • 71
  • 155
1
vote
2 answers

Auto generated id not cascading on EmbeddedId in child entity in Hibernate

When trying to insert an Entity - Awith a set Another Entity B, B should get the Auto generated Id from A but its null. Tried and failed: @MapsId("taskPKId.storyId.id") - Same error. @Embeddable class StoryId { @ManyToOne(fetch =…
Dexters
  • 2,419
  • 6
  • 37
  • 57
1
vote
1 answer

Hibernate Envers: Auditing with Embedded class in Composite Key

I am trying to activate auditing on a JPA entity with Hibernate Envers (curret version: 5.4.1.Final). Problem: The entity has an composite key (@EmbeddedId) and the key class has an @Embedded class itself. I don't get @Audit to work. Question: What…
1
vote
1 answer

JPA - two composite Embeddable fields with a shared db column?

I am trying to implement a JPA-based solution using Domain Driven Development and I have encoutered a use case that I did not find any solution to. I am using JPA with Hibernate and Spring Boot. Here is a simplified example. Lets say you have a…
1
vote
1 answer

org.hibernate.PropertyAccessException: Could not set field value [1] value by reflection

Hi guys I am new to Spring and I am getting this error in my project: org.hibernate.PropertyAccessException: Could not set field value [1] value by reflection : [class com.**.domain.identities.NurseAgencyIdentity.agencyId] setter of…
Ronny Alfonso
  • 115
  • 2
  • 10
1
vote
0 answers

Hibernate NullPointer on INSERTED id when persisting three levels using @Embeddable and cascade

I cannot cascade merge with persist three levels of entities using @EmbeddedIdin the last entity. I have three following entities: 1. Voucher 2. Rate 3. RatePerChannelOverwrite The Voucher is fetched by a service. Then I want to add new Rate to the…
Dominika
  • 388
  • 3
  • 11
1
vote
1 answer

Mapping exception in hibernate with CollectionOfElements

I am trying to get this mapping to work, but I get this strange exception message Could not determine type for: foo.ProcessUser, at table: ProcessUser_onetimeCodes, for columns: [org.hibernate.mapping.Column(processUser)] @Entity public class…
Shervin Asgari
  • 23,901
  • 30
  • 103
  • 143
1
vote
1 answer

How to use more than one Component type (Embedded, Embeddable) in annotation

I google, but all example only showing me one Component in one object, for example: https://dzone.com/tutorials/java/hibernate/hibernate-example/hibernate-mapping-component-using-annotations-1.html I want to have two Component in one object, for…
Sam YC
  • 10,725
  • 19
  • 102
  • 158
1
vote
0 answers

Hibernate NonUniqueObjectException: a different object with the same identifier value was already associated with the session

I know that there is a lot of person that have the same problem but I try a lot of solution and always the same problem that's why I ask another time. sql CREATE TABLE "ZONE"( "IZONE_ID" NUMBER(*,0) NOT NULL, "SZONE_NAME" VARCHAR2(20) NOT NULL…
djecko
  • 43
  • 4
1
vote
2 answers

Hibernate @Embeddable class throws "SQLServerException: Invalid column name" for column that is not referenced

I've been tearing my hair out about this one. I have a class pulling the object like so: public UserDTO getUser(String login) { String jql = "select entity from User as entity where entity.abcUserId = :userID "; Query query =…
Grendus
  • 85
  • 1
  • 1
  • 8
1
vote
1 answer

Removing element from JPA element Collection

Well, I have a Restaurant Entity with an Element Collection of Branches . Now my question is how do I remove a branch from a restaurant since an Embeddable object doesn't have an Id . Usually, what i would do If branch was an entity…
adn.911
  • 1,256
  • 3
  • 17
  • 30
1
vote
1 answer

Issue in JPA Cascade Save with EmbeddedId in child

I am having three class. Person,vehicle and a association class to link the person and vehicle Person package entity; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.OneToMany; import…
Magesh
  • 221
  • 2
  • 10
1
vote
1 answer

Joins to Embeddable classes in JPA2.1 specification - ContactInfo - The collection-valued path must resolve to an association field

I am trying to learn Java Persistance API. So it is written on page174 of JPA 2.1 specification : In the following example, contactInfo denotes an embeddable class consisting of an address and set of phones. Phone is an entity. SELECT p.vendor FROM…
user3120128
  • 21
  • 1
  • 5
1
vote
0 answers

embedding a headless browser in C

Is any of env-js, phantom JS, slimmerJS or any of the headless browsers embeddable in a C application? This is what I need to do: I have a C application that connects to a couple of servers through HTTP & HTTPS. Up until now, I got every page,…
Alfredo Meraz
  • 139
  • 1
  • 7