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
5
votes
1 answer

How to get Hibernate to ignore table columns not in entity?

I'm using Java with Spring MVC and Hibernate. I have a bunch of entities and everything works fine. If, however, I add a column to one of my database columns, my service will start crashing until I also update the relevant java entity class with the…
AlexG
  • 1,596
  • 2
  • 17
  • 26
5
votes
2 answers

How to adjust constraints / DB mapping for Map within grails domain class

Following grails domain class: class MyClass { Map myMap } Now for myMap, grails automatically creates a new table for the elements in the map. However if I add elements which are too long (e.g. 1024 characters), I get a DB error. Can I somehow…
5
votes
2 answers

Change PrimaryKey type in model classes of Oracle db, generated with hibernate

I have a database on Oracle 11 XE and all my tables have primary keys that are NUMERIC(22,0). I have generated model classes with Hibernate tools in Eclipse. Unfortunately, all NUMERIC fields have been implemented as BigDecimals. Even fields…
xenteros
  • 15,586
  • 12
  • 56
  • 91
5
votes
4 answers

How to model a friendship relationship in hibernate?

I need to have a friendship relationship. I have a friendship class with two primary keys that each is a Member class. I am receiving following exception: org.hibernate.MappingException: Foreign key (FK_8ynretl1yt1xe3gcvfytrvpq:Friendship [])) must…
Jack
  • 6,430
  • 27
  • 80
  • 151
5
votes
2 answers

Hibernate with Glassfish 4.1

I've setted up Hibernate on Glassfish 4.1 but I'm having problems with persistence. I'm able to read data, but cannot write to BD (changes appear to not be commited). My current persistent.xml looks like this:
martins.tuga
  • 1,662
  • 1
  • 16
  • 20
5
votes
1 answer

Hibernate - how to use cascade in relations correctly

I'm using hibernate in my spring mvc application and have a question about cascade. I see to many similar questions about it, but none of them can answer my question. Suppose I have User and UserPosition objects. User has a collection of…
hamed
  • 7,939
  • 15
  • 60
  • 114
5
votes
4 answers

JPA: Selecting subset of entity won't load @OneToOne property

I have a gigantic entity and I'd like to load its subset (ID and baz property): @Entity public class GiganticEntity { @Id Long id; @OneToOne(mappedBy = "giganticEntity") Foo foo; @OneToOne(mappedBy = "giganticEntity") Bar…
Xorty
  • 18,367
  • 27
  • 104
  • 155
5
votes
3 answers

How to create a customerNumber generator for each company in Hibernate

I have a table of customers, each customer belongs to a company, companies want their customer numbers to start at 0 and increment as they add customers and when companyB adds a customer, companyA's customer numbers shouldn't be affected. CustomerId…
Jan Vladimir Mostert
  • 12,380
  • 15
  • 80
  • 137
5
votes
1 answer

Hibernate performs twice the same query if a bidirectional relationship is defined

I'm using Hibernate 4.3.8.Final and Oracle 11g database. I defined a very simple bidirectional relationship between two entities, named Parent and Child, as follows (getters and setters are omitted): @Entity public class Parent { @Id …
Claudio Tasso
  • 417
  • 5
  • 13
5
votes
2 answers

Set creation and update time with Hibernate in Xml mappings

I'm using Hibernate with Xml mappings. I have an entity that has two fields creationDate and updateDate of type timestamp, that have to be filled with the current UTC time when the entity is persisted and updated. I know about the existence of the…
Mark
  • 67,098
  • 47
  • 117
  • 162
5
votes
2 answers

org.hibernate.hql.internal.ast.QuerySyntaxException: EdbmsEmployee is not mapped [from EdbmsEmployee edbmsEmployee where edbmsEmployee.employeeid=?]

I am working on spring 3 hibernate 4 and new to ORM. so getting below Exception please help. I know Question for this exception is already asked but in my case i am still facing the issue after trying those solution. Below is my Entity class …
Sumit Dhakd
  • 63
  • 1
  • 1
  • 4
5
votes
3 answers

How to query using an Enum parameter mapped as ORDINAL using JPA and Hibernate

I need to get data from database by enum type. I have following enum: public enum ShopType { VANS("VANS"), ATTICUS("ATTICUS"), FAMOUS("FAMOUS") ShopType(String label) { this.label = label; } private String label; …
user3127896
  • 6,323
  • 15
  • 39
  • 65
5
votes
1 answer

MappingException: Named query not known

Trying to learn Hibernate, i am trying to learn how to execute NamedQuries but evertime i am getting Exception in thread "main" org.hibernate.MappingException: Named query not known.Please help me out here Error (only the message, not showing…
NoobEditor
  • 15,563
  • 19
  • 81
  • 112
5
votes
2 answers

Duplicate entry 'string1-string2' for key 'PRIMARY'

In a Spring MVC application using hibernate and jpa over a MySQL database, I am getting the following error message about a child entity whenever I try to save a parent entity that includes the child entity: Duplicate entry 'string1-string2' for…
CodeMed
  • 9,527
  • 70
  • 212
  • 364
5
votes
1 answer

WITH Clause : Subquery Factoring using Hibernate

WITH dept_count AS ( SELECT deptno, COUNT(*) AS dept_count FROM emp GROUP BY deptno) SELECT e.ename AS employee_name, dc.dept_count AS emp_dept_count FROM emp e, dept_count dc WHERE e.deptno = dc.deptno; How can we map the…