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

Insert records in multiple tables with same ID with Nhibernate hbm mapping

I have two tables, Table 1 has a identity column(AttachmentID) and other fields, Table 2 has a AttachmentID column which is FK of Table1.AttachmentID and PK(not identity column), so Table1.AttachmentID = Table2.AttachmentID, records may or may not…
Sumit Bansal
  • 63
  • 10
2
votes
1 answer

Hibernate - Cascading type from annotations to hbm.xml

I'm currently asked to convert our POJOs hibernate annotations to hbm.xml files, But I came across two annotations that I can't "translate" and doesn't find a complete answer to my question, What cascading type should I use to reflect the…
Erunayc
  • 97
  • 1
  • 12
2
votes
2 answers

Legacy database structure Hibernate mapping issue

I am having trouble mapping the following database structure (shortened for brevity with just PKs/FKs and a few extra columns: Policy Policy_Id (PK) ... Risk Risk_Id (PK) ... Party Party_Id (PK) ... PartyRole PartyRole_Id (PK) Party_Id (FK…
Strelok
  • 50,229
  • 9
  • 102
  • 115
2
votes
0 answers

Upgrade to Hibernate 4.x default_entity_mode=dynamic-map exception

I'm trying to upgrade hibernate from 3.6.10 to 4.3.11, but I'm facing multiple problems. First of all, in hibernate 3.x there was EntityMode session, something of that: Session session = sessionFactory.openSession().getSession(EntityMode.MAP); but…
Getodac
  • 119
  • 7
2
votes
1 answer

NHibernate Property Mapping, best practise for type attribute?

I have a little doubt for mapping of property in hbm file. Sometimes I've mapped the string field of my db in this way: but the same mapping can be wrote in this way:
Luca Petrini
  • 1,695
  • 2
  • 28
  • 53
2
votes
1 answer

can you re-use nhibernate mapping files for tables with common columns

We have a bunch of lookup tables that all share the same columns (ID,Code,Description, etc) and my co-worked just asked me if we could build a generic lookup.hbm.xml mapping file and use it as a base for all the other lookup tables. Does nhibernate…
MarkDav.is
  • 640
  • 1
  • 8
  • 16
2
votes
2 answers

How to visualize NHibernate hbm.xml files

Are there any tools or clever methods for me to I visualize the contents of NHibernation hbm.xml files? I would like to load hbm files into a designer and see them as entities with relations
user375049
  • 277
  • 6
  • 16
2
votes
0 answers

NHibernate: Filtering a child collection which includes a join

I have the following mapping files:
Nigel
  • 2,150
  • 3
  • 20
  • 22
2
votes
1 answer

Strange behavior on one-to-one and many-to-one (unique=true) fetching in hibernate

I'm trying to achieve lazy load on the following. User.java public class User { private int id; private String userName; private String password; private Employee employee; //getter and…
The Coder
  • 2,562
  • 5
  • 33
  • 62
2
votes
2 answers

Using nHibernate to map two different data models to one entity model

I have two different data models that map to the same Car entity. I needed to create a second entity called ParkedCar, which is identical to Car (and therefore inherits from it) in order to stop nhibernate complaining that two mappings exists for…
Dan
  • 29,100
  • 43
  • 148
  • 207
2
votes
3 answers

How do I map List> in NHibernate?

I have a Rotation class, which contains references to multiple lists of Advert objects. I would prefer an implementation where Rotation has a property of type List> to hold these, but I am unable to come up with an NHibernate mapping…
Jørn Schou-Rode
  • 37,718
  • 15
  • 88
  • 122
2
votes
1 answer

What is the equivalent of @OneToOne(optional=false) in hbm.xml files?

We use hibernate 3 with some hbm.xml files. Recently, we found that a one-to-one association (based on primary keys) is not loaded lazily and thus, making some memory issues. After a little search, we found the solution for annotation-based…
gate sumson
  • 163
  • 1
  • 11
2
votes
1 answer

hibernate one to one on foreign key

I have a main table that is D1 which has a unique id of d1Id. d1Id uniquely identifies the D1 records and is also a primary key on the table. I have table 2 which is D2 which has a d2seq as a primary key but D2 also has d1Id which is unique which…
p0tta
  • 1,461
  • 6
  • 28
  • 49
2
votes
1 answer

Mapping hbm for inheritance as @mappedclass annotation

I am using hbm files (to keep pure pojo classes with no annotation) and I'd like to use a super class with technical information (id, creation/modificaiton date and user) as @mappedclass annotation.
Rod
  • 21
  • 1
1
vote
2 answers

set lazy as true during HQL execution time

In our application, we have various objects set to lazy false based on the application needs. However, in one of the use case we want to ignore all the lazy settings within the HBM files, and get ONLY the target object. So the question is: is there…
None