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

Hibernate Projections / Lazy Loading for non required 1 to 1 Mappings

I have the following 2 classes (trimmed down for this post) public class ApplicationVO implements Serializable { /** * */ private static final long serialVersionUID = -3314933694797958587L; @Id @GeneratedValue(strategy =…
6
votes
4 answers

Because of Hibernate Mapping need to have some of the fields as @Transient but JSP does not have access to them

In Java, I have access to value of Transient fields of the class. However, I do not access to the same fields on JSP. How can I make them available to JSP? I am retrieving the values using Hibernate, I reckon a solution to this would be to…
Daniel Newtown
  • 2,873
  • 8
  • 30
  • 64
6
votes
3 answers

Which solution for Hibernate 2nd Level Cache

We are using Hibernate with JPA in a project we are currently developing. Currently running on Wildfly and future possiblity is the commercial version depending on needs. Some alternatives for the 2nd level cache are listed in the Hibernate…
Dkyc
  • 89
  • 1
  • 16
6
votes
0 answers

JPA: Why GenerationType.AUTO could not be used with InheritanceType.TABLE_PER_CLASS strategy

Could somebody explain why InheritanceType.TABLE_PER_CLASS could not use the GenerationType.AUTO strategy for primary key value generation when mapping inheritance?
skip
  • 12,193
  • 32
  • 113
  • 153
6
votes
4 answers

Is it possible to have foreign key enforced without object-to-object mapping?

Assuming the following mappings are provided: Java…
mindas
  • 26,463
  • 15
  • 97
  • 154
6
votes
1 answer

Hibernate 2nd level cache objects that are lazy=false, result in a default fetch=join, is it documented anywhere?

I experience the following apparently undocumented issue, and I want to understand if I did something wrong Did anyone encounter the same issue? Is it really not documented anywhere? or did I miss something? The behavior is this Assume the…
Eran Medan
  • 44,555
  • 61
  • 184
  • 276
6
votes
3 answers

How to delete a row & all its references from the database through Hibernate?

I'm using Hibernate 3.0 with Java. I have the following classes. Teacher.java private long id; private String teacherName; private List students; // getter-setter of all Subject.java private long id; private String subjectName; private…
RAS
  • 8,100
  • 16
  • 64
  • 86
6
votes
3 answers

UnsupportedOperationException: The application must supply JDBC connections

If I dont set anything programmatically and just call Configuration configuration = new Configuration().configure(); and use the hibernate.properties (as below) everything works just great. As soon as I try to provide username, password and…
Siddharth
  • 9,349
  • 16
  • 86
  • 148
5
votes
2 answers

Hibernate mapping multiple classes to one table using hbm.xml

I am fairly new to Hibernate and need some help with hibernate-mapping. I have 4 different classes which I want to map into one table, of which the primary key consists of attributes from 2 different classes. At the same time, I want to map only…
louis xie
  • 1,352
  • 2
  • 12
  • 22
5
votes
1 answer

Hibernate: Adding a new element to association list does not persist

I have a ManyToMany association between two Entities: COURSE and STUDENT. They are associated through a STUDENT_COURSE_MAP association table. Course.java: @Entity @Table(name="COURSE") public class Course implements java.io.Serializable { …
pballs
  • 313
  • 1
  • 3
  • 10
5
votes
1 answer

How to properly implement a owner-owned-owner2 association in java with hibernate?

I have looked for information on how to implement the following association in hibernate and although the hibernate manual is very thorough, I haven't found the following use case addressed. I have a requirement to have an association between to…
miguelf
  • 51
  • 3
5
votes
1 answer

Upgrade of Hibernate from version 3.0 to 3.6

I'm working on a project which uses Hibernate 3.0(released in 2005), though the project itself is only 4 months old. The catch is we have already written millions of lines of code. We realized we are using Hibernate 3.0 only yesterday and now we…
pavanlimo
  • 4,122
  • 3
  • 32
  • 47
5
votes
0 answers

How to call simple select Procedure that using Multiple tables from MySQL using JPA

I have a stored procedure that is returning results from multiple tables CREATE DEFINER=`root`@`localhost` PROCEDURE `GetProjectAndClientOverview`() BEGIN SELECT ( SELECT count(*) FROM projects_info) as "projects_done", (SELECT COUNT(*) FROM…
VJain
  • 1,027
  • 7
  • 17
  • 37
5
votes
2 answers

Stripping trailing whitespace from char fields in a legacy database with Grails GORM

What are the possible solutions for stripping the trailing whitespace when mapping char fields in a legacy database? I see the following options: Calling .trim() at the point of use (controller, view, etc) Override property accessors to return…
James Allman
  • 40,573
  • 11
  • 57
  • 70
5
votes
3 answers

How do I map a BigDecimal in Hibernate so I get back the same scale I put in?

In Java, new BigDecimal("1.0") != new BigDecimal("1.00") i.e., scale matters. This is apparently not true for Hibernate/SQL Server, however. If I set the scale on a BigDecimal to a particular value, save the BigDecimal to the database via Hibernate…
Robert Atkins
  • 23,528
  • 15
  • 68
  • 97