hibernate

Multiple @ManyToMany sets from one join table

Hi guys, I'm mapping a proprietary database to Hibernate for use with Spring. In it, there are a couple of jointables that, for entity A and entity B have the following schema: CREATE TABLE AjoinB ( idA int not null, idB int not null, groupEnum enum ('groupC', 'groupD', 'groupE'), primary key(idA, idB, groupEnum) ); As you ca...

How do you deal with composite pattern when using hibernate and domain-driven design?

Does hibernate has support for hierarchical data in a database where you use a parentId you use a parentId and an orderId you use Modified Preorder Tree Traversal ...

delete hibernate entity without (attempting to) delete association table (view) entry

Entity A and B have a many to many relationship using link table AtoB. If Entity A is deleted, the related links are deleted by hibernate. So far so good. My problem is that my link table is a view hiding a much more complicated relationship and works perfectly in this situation except when hiberate tries to delete the link rows from t...

NullPointerException at org.hibernate.envers.event.AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(...)

I'm using Envers to audit different fields of my entities. The framework works in general but it seems to have problems with some kinds of entity mapping. All former problems I could solve myself... but this time I'm stuck. When inserting some entity into the database I get the following exception: Caused by: java.lang.NullPointerExcep...

Where are the NHibernate/Hibernate HQL and ICriteria query examples?

I'm still quite new to NHibernate and most of it I'm getting to grips with. One area that I'm really lacking a proper understanding of though is querying (at least when it comes to anything reasonably complex). I learn best by example, but I feel that I haven't really been able to find all that many in depth querying examples on the we...

Using Hibernate Criteria API To Query Many-To-One Relationships with Projections

Hi I am trying to use Criteria API in following scenario: I have two tables, Schedule and Route (with their classes and mappings). Route has many-to-one relationship with Schedule. Route has an integer property sequence. Now I need to fetch all those Schedule objects whose associated Route objects fulfill the following condition: r...

Java Hibernate service class

Dear All! I have a painful problem regarding Java Hibernate. I have my own POJO classes in my modell, and I would like to submit query from an instance of that class, to a table of my relational DB. The problem is, that I want to submit several different queries to different tables. For example: I have a Bus class, representing buses. ...

Where I can find good Spring project example with Hibernate?

I need to make project with Spring + Hibernate, where I could find good example project how basic things are done? ...

similarity and difference between jpa and hibernate.

what is similarity and difference between jpa and hibernate. ...

Hibernate Cross Reference many-to-many Parent/Child Mapping Of Same Class

I'm having a major problem getting a parent/child relationship working for a hierarchy of a single class. Basically I have to represent a server tree like thus: Server A Server B Server C Server D Server E Server C Server D Server F Server G Note that the children of Servers B & E are th...

many-to-many JPA mapping inserting but not fething the child collections

Hello good people! i've hit a block once again with hibernate.I've posted numerous times on different aspects of the user and contact management that i've been building. The sad thing is that i didn't really have the time to play with it and understand it better before actually starting working with it. Sorry but English is not my ...

Hibernate Component with Generics

Ok, this question is best explained in code. So will try to present the most succinct example I can. Timestamped.java @Embeddable public class Timestamped<E> { private E value; private Date timestamp; ... } Foo.java @Entity @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="TYPE") public class...

Generate Hibernate Mapping Files (*.hbm.xml) from POJOS?

What's the best/easiest way to generate *.hbm.xml files from pojos? ...

ColdFusion Hibernate Generated Database

Is the database generated by Hibernate when using ormsettings.dbcreate = "dropcreate" good for production use? My Case: Basically were designing the database, and i thought it would be cool to design the objects and have hibernate create the database for me. ...

Hibernate 3.0 + ElementCollection class missing.

Hi, I created a small desktop project using Hibernate, to understand how enterprise patterns are applied in there. I'm using annotations, and wrote a class to wrap my session factory public class Hibernation { private static final SessionFactory sessionFactory; static{ try{ //sesionFactory = new org.hibernate.cfg....

Hibernate: ORDER BY using Criteria API

Hi guys, When I write a HQL query Query q = session.createQuery("SELECT cat from Cat as cat ORDER BY cat.mother.kind.value"); return q.list(); Everything is fine. However, when I write a Criteria Criteria c = session.createCriteria(Cat.class); c.addOrder(Order.asc("mother.kind.value")); return c.list(); I get an exception org.hibe...

How to get Hibernate JPA to manage list index automagically?

How do I setup a basic OneToMany relationship using a List and get Hibernate JPA to manage the sequence index number of the list automagically? Can this be done? This is my test case (more or less); @Table(name="Policy_Root") public class PolicyRoot extends BaseDomainModel { private List<Policy> policyList = new ArrayList<Policy>(...

Do I need <class> elements in persistence.xml?

I have very simple persistance.xml file: <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;...

HIbernate Free Query

hi. I would like to query using hibernate given a particulay query string I did it like this: session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); List<String> result = session.createQuery("Select item_value from cb_items").list(); session.getTransaction().commit(); session.clear(); return result; ...

hibernate ehcache only finding 1 element of a collection

so, i am really clutching at straws for ideas here. (also note: this is an intermittent problem) i have a 'parent' object with a collection of 'child' objects: <parent stuff> ... <set name="children" inverse="true" order-by="child_id"> <cache usage="read-write"/> <key column="parent_id"/> <on...