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
2
votes
1 answer

Default value for an embedded field in Hibernate. java.sql.SQLException: Field 'url' doesn't have a default value

I have an abstract class A, class B and C are subclasses of A. Class B has an embedded field d. Now when I try to save an instance of B everything is fine. However on creating an instance of Cand saving it, I get an error : java.sql.SQLException:…
Kechit Goyal
  • 3,952
  • 3
  • 20
  • 21
2
votes
0 answers

Query Return Null while apply where clause on Embeddable object

Hello EveryOne, @Entity public class Parent { @EmbeddedId private Child child; @Column(name = "TEST") private long test; getter setter } and chlid class @Embeddable public class Child { …
Charnjeet Singh
  • 3,056
  • 6
  • 35
  • 65
2
votes
1 answer

Auditing @Embeddable @ElementCollection with hibernate-envers

I have en Entity containing an @Embeddable @ElementCollection. When trying to persist this I keep getting a NonUniqueObjectException. @Entity @Audited public class Entity(){ private Long entityId; @ElementCollection private…
Robert
  • 383
  • 1
  • 5
  • 20
2
votes
1 answer

Insert object with composite primary key

I need help with this. With code is more clear, this is my function to persist: public String finalizarCompra() { Pedido pedido = new Pedido(); pedido.setEstado("almacen"); pedido.setFechaVenta(new Date()); …
Alavaros
  • 1,665
  • 7
  • 32
  • 52
2
votes
1 answer

Bulk insertion of CollectionTable elements in Hibernate / JPA

We are using Hibernate 4.2 as the backing library for JPA 2.0 entities. We have an entity like the following: @Entity public class MyEntity { .... @ElementCollection @MapKeyColumn(name = "key") @Column(name = "value") …
RJo
  • 15,631
  • 5
  • 32
  • 63
2
votes
3 answers

embeddable EJB container of WebSphere 8 can not created - NoClassDefFoundError HpelHelper

I am using the embeddable EJB container of WebSphere 8 to write some unit tests for my EJBs with JUnit4. My IDE is the RAD 8. Here is my simple test code snippet: Map properties = new HashMap(); properties.put(EJBContainer.PROVIDER, …
Tornado01
  • 23
  • 1
  • 1
  • 5
2
votes
1 answer

Embeddable with custom UserType used twice in entity

I'm using @Embeddable REmbeddedReference twice in my entity RTask. This embeddable contains QName property which type is defined as org.hibernate.usertype.UserType. @Embeddable public class REmbeddedReference implements Serializable { private…
viliam
  • 503
  • 6
  • 23
1
vote
1 answer

JPA2: Can we use multiple @ElementCollection in an Entity?

Here is the stripped down version of my code: @Entity public class Item implements Serializable{ @Id @GeneratedValue private long id; @ElementCollection(fetch=FetchType.EAGER ,targetClass=Cost.class) @CollectionTable(name="ItemCost", joinColumns =…
Veer Muchandi
  • 267
  • 5
  • 16
1
vote
1 answer

JPA, Hibernate: Composite Key with associations. Why loading but not saving?

I'm trying to map 3 entities: Question, Answer and QuestionDisplayRule. Question has many Answers and many QuestionDisplayRules each of which belong to one Question. QuestionDisplayRule has one Question, one Answer and one field with String value.…
Maxim Suponya
  • 1,419
  • 2
  • 20
  • 43
1
vote
0 answers

Getting ClassCastException while saving entity which has embeddable class with enumerated fields

Server: JBoss6 Technology: JPA 2, EJB 3.1 I have an entity which has an embeddable class that encapsulates a common group of fields, to be used many times on the same entity, as shown bellow: @Entity @Table(name = "form_x") public class FormX…
1
vote
0 answers

QueryDsl and Embeddables with OneToMany | Wierd Generated SQL Select by "."

I am expermenting querydsl with embeddable, on the following set: @Entity Class Ent1 { @Embedded Embed embed; } @Entity Class Ent2 { @ManyToOne Ent1 ent1; } @Embeddable Class Embed { @OneToMany List ent2List; } When i use…
M.eid
  • 37
  • 5
1
vote
0 answers

@OnetoMany entity in @ElementCollection

I have 2 entities and 1 embeddable object : @Entity class CourseDetails extends Course { @Id Integer id; @ElementCollection @CollectionTable(name = "course_section", joinColumns = @JoinColumn(name = "courseId"), foreignKey =…
Achyut
  • 377
  • 1
  • 3
  • 17
1
vote
0 answers

How to declare list of embeddable object that contains more lists inside?

I have a model (object) that contains few embeddable objects inside. Few of the embeddable object have List inside them. When I mark the List @ElemenetCollection, from outside there is an issue about the string list…
1
vote
1 answer

Hibernate + JPA does not find the column for an @ElementCollection table

I am trying to add an @ElementCollection but the column is not found after the setup, so I constantly receive an error. I use Spring + flyway for the set up. Everything happens in the public schema So here is my big object: @Entity @Table(name =…
user2957954
  • 1,221
  • 2
  • 18
  • 39
1
vote
1 answer

Embed complex object in entity

I want to embed the following @Embeddable public class BaseEntity implements Serializable { @Id @GeneratedValue private UUID id; @CreatedDate @Column(name = "created_date", updatable = false) private LocalDateTime createdDate; …
JangoCG
  • 823
  • 10
  • 23