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
10
votes
5 answers

How to solve hibernate error: Repeated column in mapping for entity?

HI, I have the following model: @Entity class Flight{ private Airport airportFrom; private Airport airportTo; @OneToOne(fetch=FetchType.LAZY,optional=false) public Airport getAirportFrom(){ return this.airportFrom; } …
Neuquino
  • 11,580
  • 20
  • 62
  • 76
10
votes
2 answers

How to change the Hibernate CharacterTypeDescriptor to handle empty column values

Our problem is that we can't get data (which includes empty strings with length 0) from a legacy database due to a StringIndexOutOfBoundsExceptiion originating from Hibernate's CharacterTypeDescriptor. We would like to change Hibernate's behavior to…
michaelbahr
  • 4,837
  • 2
  • 39
  • 75
10
votes
2 answers

Is it OK to have a duplicate generator named defined in the JPA persistence unit?

My situation is described here: eclipse Duplicate generator named "ID_GENERATOR" defined in this persistence unit However my question is different and the selected answer does not solve it : "Is it valid to have multiple @SequenceGenerator with the…
fabien7474
  • 16,300
  • 22
  • 96
  • 124
10
votes
7 answers

Exception in thread "main" org.hibernate.UnknownEntityTypeException: Unable to locate persister

I have to ask it, I almost tried everything. Entity Class @Entity @Table(name="UserInfo") public class User { @Id@Column(name="user_name") private String userName; @Column(name="user_id") private Integer…
vineeshchauhan
  • 765
  • 2
  • 7
  • 14
10
votes
2 answers

JPA, Hibernate: OneToOne mapping with foreign key only

Environment: Hibernate 4.1.6.final Spring 3.1.2.release Spring JPA 1.1.0.release PostgreSQL 9.1-901-1.jdbc4 I decided to rephrase the questions. There are 2 tables: public company { private Long id; private Long name; private address…
Stupidfrog
  • 2,042
  • 6
  • 25
  • 35
10
votes
1 answer

Hibernate - BigDecimal column mapping for Custom Dialect

I'm using Hibernate as our Object-Relational Mapping, with a custom dialect for an obscure database. The Entity I'm retrieving from this database has a column thus: @Column(name = "GROSS_WEIGHT", precision = 9, scale = 3) private BigDecimal…
DuncanKinnear
  • 4,563
  • 2
  • 34
  • 65
9
votes
1 answer

Mapping a localized string in Hibernate - any best practice?

I'm writing an application where all String properties must be localized, i.e. they must store a different value for every available Locale. A quick solution would be to use a Map, which can be easily mapped in Hibernate but isn't nice on the Java…
9
votes
1 answer

Hibernate persist Map without referencing another tables

Could you please help me to persist map of strings with Hibernate? Map values come from client and are random, so I don't want to store separate table for map's values Exception Caused by: org.hibernate.AnnotationException: Associated class not …
VB_
  • 45,112
  • 42
  • 145
  • 293
9
votes
3 answers

Hibernate MappingException: Logical column name cannot be null

Any idea about the below hibernate mapping exception. The below is the complete stack strace and there is no information on from which table this exception has occured. org.hibernate.MappingException: Logical column name cannot be null at…
raghavan IPS
  • 91
  • 1
  • 3
9
votes
2 answers

Hibernate mapping: ignore a super class field

I have a class A and class B public class A{ int f1; int f2; int f2; } public class B extends A{ } my question is how to ignore a field for example 'f2', in the table mapped to B?
Amir
  • 652
  • 9
  • 19
9
votes
2 answers

Avoid "Hibernate exception Null value was assigned to a property of primitive type setter" without wrappers

Having a long field on an entity managed by hibernate could be dangerous with null values. When Hibernate tries to set a null into a primitive an exception will be thrown. Best solution should be to use Long instead of long, so null can be assigned…
Ignasi
  • 5,887
  • 7
  • 45
  • 81
9
votes
3 answers

Hibernate Validator - Add a Dynamic ConstraintValidator

After learning about Hibernate Custom Validators, it has given me an interest in one topic, could I possibly create one base annotation wherein I could set which Validator to use? @Target({ ElementType.FIELD…
David B
  • 3,269
  • 12
  • 48
  • 80
9
votes
5 answers

Hibernate override "lazy=false"

I am working on a new module in an existing project. The project already has a user table, a pojo and a corresponding mapping file. The problem is that they are fetching all the properties eagerly by mentioning lazy="false". But, in my module, I am…
msmani
  • 730
  • 1
  • 7
  • 24
9
votes
2 answers

HIbernate Mapping Exception: PropertyNotFoundException: Could not find a setter

I have two POJO's ,STOCK and STOCK_DETAILS (one to many relationship). Also I have one interface IAUDITLOG (having two methods). I need to implement this interface with BOTH POJO's and want to write some implementation within those methods. But when…
user3029929
  • 471
  • 2
  • 7
  • 20
9
votes
1 answer

Hibernate does not load one to many relationships sets even with eager fetch

I have the following hibernate mapping. @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "product") private Set productLicenses = new HashSet(0); @ManyToOne(fetch =…
cloudy_weather
  • 2,837
  • 12
  • 38
  • 63