hibernate-mapping

Hibernate one to many mapping works with a list but not a set?

Sorry to bother - perhaps this is a very simple question - but for some reason the version below fails to get parsed, whereas the version with set works fine. In fact, if I just take the set version and replace set with list I get: nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from invalid m...

joining two tables with differnt join column names

I have two tables A -> B with many-to-one mapping/associations. Table B's primary key is foreign key in table A. The problem is column names in both tables are different. let's say B has primary key column "typeNumId" which is foreign key in table A as "type". How can I join both tables on this column? how can I specify mapping to ind...

Hibernate - How to map a new class to two existing Tables

I have two entities: Vehicle and Weapon classes. They are mapped respectively to Vehicle.hbm.xml and Weapon.hbm.xml. Both have their respective DAOs. All are working fine. Here's my idea. I want to create a class VehicleWeapon that has all the properties of the Vehicle and Weapon entities. I want to declare a Hibernate mapping file: Ve...

Hibernate - how to model triple join table as map?

Hi! I have a problem with mapping triple join table as a map with Hibernate using annotations. I have 3 tables: project, group, role and triple join table project_group_role with columns project_id, group_id, role_id (primary key is a pair of project_id and group_id). Database structure is given strictly from supervisor, so it would be g...

How to create reverse field mapping for an @Any Hibernate Annotation

When using the @Any annotation in hibernate how can you create the reverse mapping field, for use with orphan removal. My code looks like the example below, except that classes A and B each have their own inheritance hierarchies which is why I can not make Interface I an abstract class. public Interface I; @Entity public Class A impl...

NHibernate/Hibernate define mapping without a class

I have a particular case where I need to define a query including a table ASpecialTable for which I don't have any mapping or business class defined. However, the return type of the query is an existing business class MyBO. For that particular table, I'll never need it in my code, and it doesn't contain a primary key, or to be short: I...

Mapping BPCHAR in JPA

One of the properties in my entity is mapped to bpchar (BLANK PADDED CHAR) string. @NotNull @Column(name = "property", columnDefinition = "bpchar") private String property; When I save entity and load back, then my property is padded with spaces, that is correct from the database point of view. But I want to work in code with trimmed...

Hibernate+Spring framework project mapping error(exception)

Caused by: org.hibernate.MappingException: Could not determine type for: controler.Role, for columns: [org.hibernate.mapping.Column(ROLE)] Can you please help me on this? this is my mapping class <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hiberna...

Hibernate Mapping - foreign key referencing a composite PK

I need some help in defining the Hibernate annotation for a foreign key referencing a composite PK table. My composite PK table is FqTankType and I have defined it as private FqTankTypeId id; @EmbeddedId @AttributeOverrides( { @AttributeOverride(name = "tankTypeCd", column = @Column(name = "TANK_TYPE_CD", nullable = false...

How to debug Hibernate

Suppose I have a simple hibernate program. In this program having a hibernate query. How do I debug this query so that I can know which query elements have values and which do not. ...

Hibernate One To Many Unidirectional Mapping List

Hi, I have one-to-many relationship between parent and child Java objects. The parent object uses java.util.List that stores multiple child objects. The problem I am experiencing is when updating the parent object after I have added one or more child object(s) to the List in the parent. I am using the saveOrUpdate method to save or upda...

access data from two table.

Customer class have name property that corresponds to name field in customer table. Customer class also define the map that use for put the fieldName and fieldValue. on database customer name define in customer table and fieldvalue define in form table. now how i can retrieve customer name from customer table and fieldvalue from form ta...

hbm files in hibernate

i am working on some updation in Hibernate application. in which Struts and Spring used. we do entries of .hbm file in configration file(.cfg file). but when using spring with hibernate app we do entries in application context.xml. but i can not find configration entries in entire application. Is there any other class where we configure...

hibernate mapping files

I have a table for class UserStatus ( userId varchar, statusId bigint). Set statusId to autoincrement and specify userId as primary key for some optimisation because most request goes with userId. Using Eclipse. After reverse engineering receive such file: <class name="xxx.UserStatus" table="user_statuses" catalog="xxx"> <id nam...

Maven + Hibernate annotations schema generation

I have a bunch of classes annotated with hibernate annotations. I'm using Maven, Hibernate and Spring. How can I generated the DB schema using hibernate3-maven-plugin's hbm2ddl? ...

Hibernate auto-increment property

I know you can auto-increment an id by mapping; <id column="user_id" name="id" > <generator class="increment"/> </id> But is it also possible increment a property, what I tried so far didn't work; <property column="numeric_value" name="nr" > <generator class="increment"/> </property> ...