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
7
votes
2 answers

Maven + Hibernate annotations schema generation

I have a bunch of classes annotated with hibernate annotations. I'm using Maven, Hibernate and Spring. How can I generated the DB schema using hibernate3-maven-plugin's hbm2ddl?
7
votes
0 answers

Unidirectional OneToOne with joincolumn in target entity

How do we achieve unidirectional @OneToOne Mapping between two entities with @JoinColumn to apply on target entity. For E.g. I have two entities: @Entity public class Person { // Attaches column in the source entity i.e. Person …
sandy.sm
  • 175
  • 5
  • 14
7
votes
1 answer

HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance

I have PolicyDO and PolicyDocumentDO.relation between them is as follows PolicyDO.hbm.xml
Nalini Wanjale
  • 1,717
  • 4
  • 19
  • 24
7
votes
1 answer

How to map an immutable collection with JPA and Hibernate

I am using JPA 2.1 and Hibernate as a JPA implementation, and I want to load a relationship as an immutable collection. Let's take an example of an Employer parent entity that has an employees child collection. What can be done to instruct JPA to…
Shailendra
  • 319
  • 4
  • 14
7
votes
5 answers

Persist 1-m entities with composite primary key in hibernate

I have below 1-m relationship on entities which Mentor to Students. The mentor has composite primary key which i use as foreign key in student @Entity public class Mentor implements Serializable { private static final long serialVersionUID =…
Harshana
  • 7,297
  • 25
  • 99
  • 173
7
votes
2 answers

How to persist OffsetTime and OffsetDateTime with JPA and Hibernate?

How can I persist Java 8 OffsetTime and OffsetDateTime with Hibernate as proper SQL types (TIME_WITH_TIMEZONE and TIMESTAMP_WITH_TIMEZONE)? I found a solution for LocalTime and LocalDateTime using EnhancedUserTypes in a blog. How would the user…
Stefan K.
  • 7,701
  • 6
  • 52
  • 64
7
votes
1 answer

Hibernate composite primary key using @Embedded and @Id

I wanted to find out if hibernate supports composite primary key using a field and a component type. So I have an @Embeddable component type and I would like to use it as a primary key along with another column as a composite primary key. So my…
user290870
  • 1,591
  • 3
  • 19
  • 27
7
votes
4 answers

java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)

I have a problem in using of my own Database server with Google web application. Am using eclips (java EE IDE), installed all google plugins init, and develop a sample google web aplication , deployed it into web.Its working correctly. Now i want to…
Ramesh J
  • 794
  • 2
  • 11
  • 24
7
votes
1 answer

java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2)

I have a table "AuthorFollow" having composite key of 'authorId' and 'userId' which are primary keys in "AuthorInfo" & "UserInfo" table respectively. I am trying to save object of "AuthorFollow" in database(I am using mysql). But, I'm getting the…
Ashish Tanna
  • 645
  • 1
  • 10
  • 25
7
votes
1 answer

To map a database view with no primary key, in hibernate xml mapping

I have created a view which will be used for fetching the data only(readonly) View : Grid_View > My Hibernate hbm file
Dev
  • 3,922
  • 3
  • 24
  • 44
7
votes
2 answers

Hibernate insert query

During insertion in hibernate query i'm passing some fields as table class objects which i've mapped to corresponding tables, The query works fine but the query is becoming too large because each of these mapped objects are getting updated…
Denny
  • 105
  • 1
  • 2
  • 7
7
votes
4 answers

Map entity using query in Hibernate

consider table sales (id, seller_id, amount, date) and here is a view that is generated from sales using query SELECT seller_id, SUM(amount) FROM sales GROUP BY seller_id total_sales (seller_id, amount) I want to make an entity for total sales but…
nimcap
  • 10,062
  • 15
  • 61
  • 69
7
votes
2 answers

Do we need Hibernate mapping In this scenario?

I am new to hibernate. Please help me. I have 2 tables named Employee and Country.I need to save the Employee with selected country.In my case , I will nowhere get employee details back and show it on UI. Do i need to maintain mapping(onetoone…
Java P
  • 2,241
  • 6
  • 31
  • 45
7
votes
2 answers

One to many hibernate join if column names are different

I have three tables with following structure - Contract -> contract_id(primary), customer_company_id, Vendor_company_id Company -> Company_id(primary), creation_date, created_by Company_Timeline -> Timeline_id(Primary), Company_id,…
Pramod Kumar
  • 7,914
  • 5
  • 28
  • 37
6
votes
9 answers

org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]

I'm trying to set up a small working sample of Hibernate that I found here However when I run the code I get the follwing error Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.sample.Person] at…
seeker
  • 6,841
  • 24
  • 64
  • 100