Questions tagged [hibernate-mapping]

Hibernate uses mapping metadata to find out how to load and store objects of the persistent class. The Hibernate mapping could be specified using configuration files or annotations.

Hibernate uses mapping metadata to find out how to load and store objects of the persistent class. The Hibernate mapping could be specified using configuration files or annotations.

This tag should be used for questions regarding issues with the definition of Hibernate mappings.

3217 questions
18
votes
6 answers

Adding an enum as a class property in HBM

I am trying to create a class in HBM file which contains an Enum as a field. The HBM is similar to this: and let's say…
Avi Y
  • 2,456
  • 4
  • 29
  • 35
17
votes
1 answer

Spring and/or Hibernate: Saving many-to-many relations from one side after form submission

The context I have a simple association between two entities - Category and Email (NtoM). I'm trying to create web interface for browsing and managing them. I have a simple e-mail subscription edit form with list of checkboxes that represents…
Rafał Wrzeszcz
  • 1,996
  • 4
  • 23
  • 45
17
votes
3 answers

How to best map results from an SQL query to a non-entity Java object using Hibernate?

I have a Hibernate managed Java entity called X and a native SQL function (myfunc) that I call from a Hibernate SQL query along these lines: SQLQuery q = hibernateSession.createSQLQuery( "SELECT *, myfunc(:param) as result from…
Johan
  • 37,479
  • 32
  • 149
  • 237
16
votes
1 answer

java, hibernate: mapping property with a query

I have an entity with a property "quantity", this value is not a table field but is dynamically calculated with an hql query. So, is possibile to add this value in my entities and make hibernate calculate it when I load my entities?
blow
  • 12,811
  • 24
  • 75
  • 112
16
votes
5 answers

Solving LazyInitializationException via ignorance

There are countless questions here, how to solve the "could not initialize proxy" problem via eager fetching, keeping the transaction open, opening another one, OpenEntityManagerInViewFilter, and whatever. But is it possible to simply tell Hibernate…
maaartinus
  • 44,714
  • 32
  • 161
  • 320
16
votes
7 answers

Not-null property references a null or transient value for persisted value

I'm trying to persist two different entities using JPA1, with the Hibernate implementation. The code for this is as shown below: Parent entity class @Entity @Table(name = "parent") public class Parent implements Serializable { {...} private…
renke
  • 1,180
  • 2
  • 12
  • 27
15
votes
1 answer

JPA Entity Mapping which is related based on two other entity mappings

Not sure if this is possible but trying to map WorkflowInstancePlayer player which is related based on two other entity mappings, WorkActionClass and WorkflowInstance in the entity below. public class Action implements Serializable { @Id private…
jeff
  • 3,618
  • 9
  • 48
  • 101
15
votes
3 answers

What is the difference between @Entity in Hibernate and JPA

When i am doing sample Hibernate standalone program, little bit confusing was created in my mind with the usage of @Entity annotation. Here my question is, I have one persisted class with @Entity from javax.persistence package then it's working fine…
jettisamba
  • 681
  • 2
  • 7
  • 14
14
votes
3 answers

Hibernate Mapping Exception : Repeated column in mapping for entity

There is a mapping exception for a particular entity. Cant figure out from where the problem is arising. I checked all the mappings 3 times from start to end. Still i am getting a Mapping Exception. Email to employee is mapped only once. but still…
bali208
  • 2,257
  • 7
  • 40
  • 43
14
votes
3 answers

JPA ManyToMany unidirectional relationship

Lets say we have two Entities, Entity Node and Entity Cluster. A Cluster has many Nodes. A Node can belong to multiple Cluster. So in Cluster there is a @ManyToMany annotation. However Node is unaware of any Cluster it belongs to (intentional). When…
dumb_terminal
  • 1,815
  • 1
  • 16
  • 27
14
votes
5 answers

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

My Code: I am trying to do either update/insert. It gets inserted properly, only problem is when I try to update it gives below error message. private String sessionType=null; public String getAccountsDetails(List accountList) { …
TechFind
  • 3,696
  • 18
  • 47
  • 62
13
votes
3 answers

Hibernate @OneToOne mapping with a @Where clause

Will this work - @OneToOne() @JoinColumn(name = "id", referencedColumnName = "type_id") @Where(clause = "type_name = OBJECTIVE") public NoteEntity getObjectiveNote() { return objectiveNote; } This is what I am trying to do - get the record from…
nuaavee
  • 1,336
  • 2
  • 16
  • 31
13
votes
3 answers

What is the use of bag tag in Hibernate?

I need to know how to use the bag tag and what is the purpose of it?
gokul
  • 153
  • 1
  • 3
  • 11
13
votes
5 answers

ERROR: ORA-02289: sequence does not exist - org.hibernate.exception.SQLGrammarException: could not extract ResultSet

I am creating a basic hibernate application for employee table in which I am adding, updating, deleting and displaying the record with the help of ManageEmployee class. Actually, ManageEmployee is my test class and i am using Employee.java and…
user2682305
  • 171
  • 1
  • 1
  • 6
13
votes
1 answer

Hibernate: Migrating from mapping to annotations - is it possible to mix hbm and annotation?

I'm currently migrating my project from Hibernate HBM Mappings to Annotations. Everything was easy as far as i dealt with small classes. But I have same huge classes and i try to mix both mapping and annotations for this class. I read that this was…
marcam
  • 145
  • 1
  • 1
  • 8