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

Hibernate lazy loading for reverse one to one workaround - how does this work?

I was having problems today with lazy loading not working when using a mapped by collection. I found this excellent article that seems to fix the problem http://justonjava.blogspot.co.uk/2010/09/lazy-one-to-one-and-one-to-many.html One thing I do…
RNJ
  • 15,272
  • 18
  • 86
  • 131
8
votes
1 answer

Hibernate Mapping Parent/Child Relationship

I have a database table which contains a simple self parent/child relationship (categories) like this: +------------+----------+--------------------+ | categoryid | parentid | category_name | +------------+----------+--------------------+ | …
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
8
votes
1 answer

Spring LocalContainerEntityManagerFactoryBean scanForPackages and Hibernate package-level type definitions

In Spring 3.1 and higher the LocalContainerEntityManagerFactoryBean is supposed to be able to configure the JPA EntityManagerFactory without a persistence.xml. The configuration is included in the bean definition for …
JayL
  • 2,819
  • 4
  • 22
  • 15
8
votes
2 answers

Avoid Circular Dependency

I am developing a travel management application. The design in question is something like following : Each person in a tour is designated as a Traveler. Each Traveler has a Passport. Now, a Traveler can be a MainMember or a SubMember, depending on…
8
votes
2 answers

Hibernate update query with innerjoin

I have the following MySQL update query with inner join: UPDATE Country AS c INNER JOIN State s ON c.CountryID = s.CountryID INNER JOIN City cy On s.StateID = cy.StateID SET c.Active='Y', s.Active='Y',cy.Active='Y' WHERE …
edaklij
  • 4,121
  • 11
  • 31
  • 43
8
votes
3 answers

Disabling JPA Hibernate schema validation for a single entity

I have a JPA entity that I use as the result class of a native query. As such, the entity is not valid per se (as it does not have a table). I use Hibernate 4.1.x as my JPA provider, which performs a schema validation during startup and consequently…
Thilo-Alexander Ginkel
  • 6,898
  • 10
  • 45
  • 58
8
votes
1 answer

What does a relationship owner mean in Hibernate?

@Entity public class Troop { @OneToMany(mappedBy="troop") public Set getSoldiers() { ... } @Entity public class Soldier { @ManyToOne @JoinColumn(name="troop_fk") public Troop getTroop() { ... } I am…
mogronalol
  • 2,946
  • 8
  • 38
  • 56
7
votes
3 answers

Hibernate mapping: OneToMany and OneToOne on child object property

Here is parent class Enterprise. It has employers and one of them is president of enterprise. @Entity class Enterprise { // fields @OneToMany public List getEmployers() // implementation @OneToOne public Employee…
Artyom Chernetsov
  • 1,394
  • 4
  • 17
  • 34
7
votes
2 answers

Hibernate Many-to-many association: left hand side collection contains elements, but right hand side collection is empty

I got a problem with a many to many association in my persistence layer. My scenario is the following: A user can has several roles and a role can have several user attached to it. During the tests I encountered a strange behavior. I created role…
Flo
  • 27,355
  • 15
  • 87
  • 125
7
votes
1 answer

SQLServerException: The conversion from timestamp to TIMESTAMP is unsupported.

Recently made some database changes and something is messed up with the hibernate mapping. Hibernate Mapping: ...other…
Adam
  • 4,590
  • 10
  • 51
  • 84
7
votes
1 answer

How to programmatically bind Hibernate Type for selected entity fields?

I'm looking a way to bind Type for specific entity fields during entity manager configuration phase. I need it to be able to apply extra "rules" to target entity field using external source without entity class changes. So basically I'm trying to…
user9440008
  • 572
  • 1
  • 9
  • 21
7
votes
2 answers

Mapping problem with Hibernate

I am new to hibernate and i am having trouble with specifying the location of the mapping file in hibernate.cfg.xml file. I have created an Event object in org.hibernate.tutorial.chapter1.domain.Event.java package with its corresponding…
special0ne
  • 6,063
  • 17
  • 67
  • 107
7
votes
4 answers

hibernate foreign key issue : Error executing DDL "alter table..."

I have a pretty simple object structure that is giving me an error I'm not able to resolve. Have done a bunch of searching, and I think this must be a pretty common use case, so not sure what the issue is. I have these three classes: @Entity public…
badperson
  • 1,554
  • 3
  • 19
  • 41
7
votes
1 answer

How do I join on two columns in the hibernate mapping file using the tag?

I need to map a single class to two tables (both with multiple columns primary key). Let's say TABLE1 has id1, id2, id3 and TABLE2 has id1, id2 as primary keys. Now when writing the mapping file I would do something like the…
despot
  • 7,167
  • 9
  • 44
  • 63
7
votes
2 answers

Hibernate 3.5 or 3.6 with no supporting to @Any annotation?

I'm currently working on a system migration (from hibernate 3.2.2.GA with JPA1 to hibernate 3.6 with JPA2. The migration itself is very simple, there are no major updates to do (in fact, I don't think there is any at all). The problem I'm facing is…
Lucas de Oliveira
  • 1,642
  • 11
  • 16