Questions tagged [hbm]

A Hibernate (and NHibernate) feature that allows for both HQL and SQL queries to be stored in a file

A Hibernate (and NHibernate) feature that allows for both HQL and SQL queries to be stored in a file ending with *.hbm.xml. The main advantage is that your query is precompiled when the application starts up, and any errors in the query can be caught ahead of runtime.

165 questions
54
votes
2 answers

How can I map "insert='false' update='false'" on a composite-id key-property which is also used in a one-to-many FK?

I am working on a legacy code base with an existing DB schema. The existing code uses SQL and PL/SQL to execute queries on the DB. We have been tasked with making a small part of the project database-engine agnostic (at first, change everything…
Jesse Webb
  • 43,135
  • 27
  • 106
  • 143
18
votes
6 answers

Adding an enum as a class property in HBM

I am trying to create a class in HBM file which contains an Enum as a field. The HBM is similar to this: and let's say…
Avi Y
  • 2,456
  • 4
  • 29
  • 35
9
votes
1 answer

could not delete collection : [NHibernate.Exceptions.GenericADOException]

I have Two Table , tableA and tableB. tableA have column : tabAId, col2, col3 (tabAId primaryKey and Identity column.) tableB have column : tabAId, name (tabAId is not null) I have create Bag in hbm file of tableA, to maintain relation ship.
Amit Kumar
  • 5,888
  • 11
  • 47
  • 85
7
votes
6 answers

Mapping a boolean with hibernate

I'm running into trouble with hibernate. I recently set my hbm2ddl to validate, and it has been complaining a lot about wrong datatypes. I have fixed every problem except for booleans. I have a field opener in my class, which is mapped as:…
Maarten Blokker
  • 604
  • 1
  • 5
  • 23
7
votes
3 answers

Mapping Java byte[] to MySQL binary(64) in Hibernate

I'm having some trouble mapping a byte array to a MySQL database in Hibernate and was wondering if I'm missing something obvious. My class looks roughly like this: public class Foo { private byte[] bar; // Getter and setter for…
spaaarky21
  • 6,524
  • 7
  • 52
  • 65
7
votes
0 answers

Reuse HQL named queries fragments

I'm using HQL named queries (which are defined in XML files) to query my database using Hibernate. Some of the queries are quite complex and I find myself copy-pasting substantial parts of one query to another, similar one. I was wondering if it's…
Stefan Haberl
  • 9,812
  • 7
  • 72
  • 81
7
votes
4 answers

Generating Hibernate hbm xml files & entities classes from existing DB schema

How can I generate Hibernate hbm xml files & entities classes from an existing DB schema?
user137505
6
votes
1 answer
6
votes
2 answers

How do I output the HBMs that Fluent NHibernate Creates?

I am trying to debug my fluent application and would like to see what the generated files look like. What are the ways to view them? Is there a way to export them?
Nick
  • 19,198
  • 51
  • 185
  • 312
6
votes
2 answers

NHibernate Discriminated Subclasses of a Joined-Subclass

Here's my heirarchy: class abstract Entity { /*members*/ } // mapped to entity table class abstract User : Entity { /*members*/ } // mapped to user table class Employee : User { /*no members*/ } // no table, discriminator = "E" class Contractor :…
Travis Heseman
  • 11,359
  • 8
  • 37
  • 46
6
votes
6 answers

Hibernate - update the primary key 'id' column in the table

In my Java applicaion, I am using hibernate .hbm file to access database; Is this possible to update the primary key 'id' column in the table; Where the 'id' column in my .hbm file is like:
It's me
  • 1,065
  • 6
  • 15
  • 30
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
3 answers

Breaking changes with NHibernate 4 upgrade

I can see what's new and fixed in NHibernate 4.0 I would like to know if anyone has had issue with hbm mappings upgrading from NHibernate 3 to 4? I fear that more focus is going on fluent mapping these days. I can test for the more obvious breaking…
dove
  • 20,469
  • 14
  • 82
  • 108
4
votes
1 answer

@Audited annotation in Hibernate hbm file

I am using Hibernate as my orm in my application. Now I want to integrate it with Envers. At present I am generating entity using hbm files. In that case how can I mention in hbm file that generate class must have @Audited…
Narendra
  • 5,635
  • 10
  • 42
  • 54
4
votes
2 answers

Failed hibernate mapping: An association from the table X refers to an unmapped class Y

Hi I'm trying to map this pojo Rent class to create his hibernate mapping file . Rent.java (POJO): public class Rent implements Serializable { private static final long serialVersionUID = 1L; Employee employee; Client client; …
user2298581
  • 532
  • 3
  • 11
  • 37
1
2 3
10 11