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.

learn more… | top users | synonyms

1
vote
1answer
30 views

Unable to make 'many-to-many' relation between Person and Address class

How do I make many-to-many relation between 2 classes Person and Address ? Following is the POJO for Person and Address respectively. Person : public class Person { private int personID; ...
0
votes
1answer
39 views

Why am I getting org.hibernate.id.IdentifierGenerationException?

As I run my main class (Runner) program I get the following exception : org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property: country I don't know ...
0
votes
2answers
52 views

The concept for one-to-one mapping. Explain the mapping

How to define a One-to-One relation between 2 classes ? I think I am going wrong somewhere,conceptually. I don't know what ,but it is. Let us suppose there are two classes named Country and PM : ...
1
vote
2answers
41 views

Unable to make 'one-to-one' relationship between the two classes

What shall I do in the following xml to make a one-to-one relationship between Country class and PM class ? <class name="pojo.Country" table="country"> <id name="c_id"> ...
2
votes
1answer
34 views

What shall I mention for the 'name' attribute ? Why this validation error?

I am trying to make a one-to-one relation between Country class and PM class.This is the xml mapping I tried to make.But there is something wrong with the xml as the error says. Attribute "name" is ...
1
vote
1answer
32 views

What does the 'sort' attribute do?

Following is the snippet from the hibernate mapping file, of the class named m1. <class name="pojo.m1" table="m1"> <id name="r_no"> <generator class="increment" /> ...
0
votes
0answers
16 views

How do I setup Hibernate reverse engineering to generate update and insert properties in the generated hbm.xml mapping files

I am using Hibernate 4.1 to reverse engineer (using hibernate.revenge.xml) to generate both my mapping files (*.hbm.xml) and my pojo's from an MS-SQL database. Some of the tables contain calculated ...
1
vote
1answer
20 views

hibernate non-unique one to one mapping

we are working with a legacy database and I'm wondering if our set up is at all possible with Hibernate the way it is: We have two tables Entity and EntityDef CREATE TABLE entity ( id DOUBLE, ...
0
votes
1answer
17 views

Hibernate 3 Annotation Mapping Issue

I am new to Hiberante 3. I am facing issues when I am trying to map 3 tables which has the below relations. ITEM_MASTER (Table): ITEM_ID-PK LOCATION_ID ITEM_MASTER_ATTR (Table): ITEM_ID - FK ...
1
vote
2answers
62 views

After changing JDBC to hibernate the application runs very slow

Previously I used JDBC in my application and it was running very fast, but I have modified it to use Hibernate which made it too slow, especially when it needs to open a page that has a dropdown box ...
0
votes
0answers
10 views

Hibernate not fetching Join result

I have two tables represented as following in Hibernate. Class A { @Id @Column(name = "a_id") private Long a_id; } Class B { private Long a_id; private A objA; @ForeignKey ...
0
votes
1answer
31 views

Problems mapping entities of single_table inheritance

I use hibernate 4. I use single_table inheriatnce strategy for entities JuniorUser extended by ExpertUser. It is mapped in Answer entity with type JuniorUser like: @NotNull @ManyToOne(fetch = ...
0
votes
1answer
21 views

How to get datasource from Hibernate Configuration

I would like to get a datasource from a hibernate Configuration programmaticaly. Here is the code that I wrote : public static DataSource getDatasource(Configuration configuration){ ...
0
votes
1answer
16 views

Hibernate Criteria query by Example mapping

There is only one Envelope object and 2 Invoice object which are mapped by this Envelope.When I try to query with following code, it returns 2 Envelope object which are same. I think there is a ...
0
votes
0answers
35 views

Spring Template Project jpa annotations

I have a one to many relationship: Order and Items. An Order may have lots of items The code below (all code) is auto generated by Spring Template project: On the Order Side: ...
1
vote
2answers
22 views

Hibernate Restricitions.ilike runs into error

Executing the following restrictions runs into following error Message: java.lang.String cannot be cast to java.lang.Integer if (suburbid > 0) { ...
0
votes
1answer
36 views

Performing a Hibernate Join on two tables with a One to Many Association

I basically have a database with two tables in it with the following schema: Employee |id|Age|Sex| Table |Table_id|Emp_id|Location| My employee.hbm.xml file looks like: <property ...
1
vote
1answer
90 views
+100

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 ...
0
votes
0answers
34 views

Hibernate mapped by hitting database

I have a one to one relationship in hibernate between Man and Car (excuse the simplistic example) In Man I have @JoinColumn(name = "CAR_ID", referencedColumnName = "id") @OneToOne(cascade = ...
0
votes
1answer
59 views

getting org.hibernate.InvalidMappingException: Unable to read XML

I am using NetbeansIDE 7.2. and pgAdmin III PostgreSQL 9.2 with Database name "StudentReports". I know a little of Hibernate and generating JasperReports using native SQL through JDBC Connection. But ...
0
votes
0answers
8 views

hibernate criteria query with multiple mapping

I have to modify a hibernate criteria query. The mapping is:- ClassA n:m ClassB 1:1 ClassC. Here I have to find a list of ClassA instances in the DB which have the exact set of ClassC instances ...
0
votes
0answers
19 views

Cannot fetch data from database using spring and hibernate

i am developing a spring and hibernate application and got into a problem. i have a many to many related entity's with join table which are: @Entity public class Invoice implements ...
3
votes
1answer
112 views

How to avoid updating unchanged fields?

I need to configure my hibernate to avoid updating those fields that has not been changed. So I have added the following annotation to my class but it crossed the Entity, and dynamicUpdate. ...
1
vote
0answers
36 views

I do not understand this mapping file.What does many-to-many tag here do?

I have a problem understanding the following hibernate mapping xml. <class name="pojo.NewClass" table="emp_master"> <id name="emp_code"> <generator class="increment" ...
1
vote
1answer
60 views

what type of mapping is this?

With the hibernate mapping file as shown : <hibernate-mapping> <class name="pojo.Ghazal" table="ghazal"> <id name="s_no"> <generator class="increment" ...
2
votes
1answer
40 views

Hibernate and MS SQL Server Identity column

I'm new to Hibernate and am unable to use an Identity column. When I run my java program using identity as generator, it gives the error that it "...cannot insert default or null value" in the ...
0
votes
1answer
28 views

How to set fetch=“Join” and lazy=“False” in <key-many-to-one > mapping in hbm.xml

I have table mapping in .hbm.xml file as follows. when i set lazy loading to false , it is not working. It is fire lots of select query to db to load other table. <class name="GroupConfigDO" ...
0
votes
1answer
19 views

How to insert using hibernate 4.1.10.Final?

I am using hibernate 4.1.10.Final to insert data into database, but it throws the following exception, I have three tables, development and address . Development has an object of address in itself. ...
0
votes
2answers
78 views

how to implement auto increment id field per table with Hibernate and postgresql for one to many relationships

I have 4 entities one-to-many Message entity: @Entity @Table(name = "Messages") public class Message { ... @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "messagesounds_id") ...
1
vote
1answer
29 views

How to load only ids from Many to Many mapping tables?

In a Many to Many relation between two table with a Mapping table in between, how can I only load ids for the second entity. Following is the example to explain what I want to achieve here. Below is ...

1 2 3 4 5 30
15 30 50 per page