hibernate

How can I set the schema name used by hibernate entities at query time?

Our application uses Hibernate for ORM, and stores data in several schemas, accessing them with a user whose grants are customized for the application. The schema names are determined at runtime based on data; it's not feasible to include their names in the entity mapping documents. This means that I need a way to tell Hibernate to use...

hibernate - pattern for mapping a default entity?

Is there a sleek way to map a default database object in Hibernate? For example, in this class, a Foo should always be able to return a Bar, whether it's custom defined for the Foo, or it comes from a default value that's stored in the database somewhere. Users of Foo should be able to set a custom Bar object in it, but they don't ne...

Hibernate and currency precision

I have a hibernate mapping as follows: <hibernate-mapping> <class name="kochman.elie.data.types.InvoiceTVO" table="INVOICE"> <id name="id" column="ID"> <generator class="increment"/> </id> <property name="date" column="INVOICE_DATE"/> <property name="customerId" column="CUSTOMER_ID"/> <property name="schoolId" column="S...

NHibernate Mapping intermediary table

Hi I'm looking for some help in mapping the following tables to a hibernate mapping file: I'm trying to fill the localCalandarGroups List with related localCalendarGroups when loading my userVOs. I'm using a intermediary table(user_localCalendarGroup) to keep the user and localCalendarGroup ids public class UserVO { public virtua...

Help in hibernate

Hi, Currently in my project i am using "all-delete-orphan" on child & it works fine i.e. if i remove parent then all of its child are removed. But if i dont remove parent and update it as just remove one child entry and add another child entry, then the child is not getting removed from db. ...

Unit testing a Hibernate driven application?

This may be a naive question, but I am new to both the junit and hibernate frameworks and I was wondering what the best way to go about unit testing an application that is largely calls to hibernate, or if it is even necessary to do so? What is the best practice here? EDIT: Spring seems to be the big suggestion here. Unfortunately thi...

Sample Hibernate program?

How would I write a simple program using Hibernate in Java, with MySQL as a backend? ...

Hibernate inner join mapping - string where id.

Hi, I'd like to map the following sql in NHibernate. Will I need to make a separate entity object i.e RoomTypeVO mapped to tb_tags to do this? Any help much appreciated. SELECT dbo.tb_rooms.id, dbo.tb_rooms.name, dbo.tb_tags.name AS 'roomType' FROM dbo.tb_rooms INNER JOIN dbo.tb_tags ON (dbo.tb_rooms.typeID = dbo.tb_tags.id)...

HibernateTransactionManager(Spring) with multiple Session Factories

I have a DAO implementation that uses a HibernateTransactionManager for transaction management and the application has 2 session factories. I am getting an exception at the transactionManager.commit() line below. Does performing Hibernate operations within a transaction manager related to a different session factory cause problems? Tran...

hibernate criteria - querying tables in n:m relationship

I'm trying to build a query with hibernate criteria for the following scenario: Two entities: Indicator and report (each with their own tables, classes etc.) an indicator can be used in zero to many reports a report uses zero to many indicators therefore, I have an intersection table to store the relationship the relationship is define...

Ordering return of Child objects in JPA query

So if my JPA query is like this: Select distinct p from Parent p left join fetch p.children order by p.someProperty I correctly get results back ordered by p.someProperty, and I correctly get my p.children collection eagerly fetched and populated. But I'd like to have my query be something like "order by p.someProperty, p.children.some...

JPA/Hibernate query optimization with null values

I'm using Hibernate's implementation of JPA and am seeing poor performance as multiple SQL queries are issued for each entity that is fetched. If I use a joined JPA query it generates just one SQL query but doesn't find rows will null relationship. Example, consider this simple schema. A person lives at an address and is employed by a c...

Table per Concrete Class Hierarchy in Hibernate

I have the following Hibernate Mapping, which has to be mapped using the Table per Concrete Class Hierarchy: <hibernate-mapping package='dao'> <meta attribute='class-description'></meta> <class name='PropertyDAO'> <id name='id' column='id_property'> <generator class='assigned'/> </id> <property name='address...

An alternative to Hibernate or TopLink?

Is there a viable alternative to Hibernate? Preferably something that doesn't base itself on JPA. Our problem is that we are building a complex (as in, many objects refer to each other) stateful RIA system. It seems as Hibernate is designed to be used mainly on one-off applications - JSF and the like. The problem is mainly that of lazy...

Sparse data: efficient storage and retrieval in an RDBMS

I have a table representing values of source file metrics across project revisions, like the following: Revision FileA FileB FileC FileD FileE ... 1 45 3 12 123 124 2 45 3 12 123 124 3 45 3 12 123 124 4 48 3 12 123 124 5 48 3 12 123 ...

What are my options to store and query huge amounts of data where a lot of it is repeating ?

I am evaluating options for efficient data storage in Java. The data set is time stamped data values with a named primary key. e.g. Name: A|B|C:D Value: 124 TimeStamp: 01/06/2009 08:24:39,223 Could be a stock price at a given point in time, so it is, I suppose, a classic time series data pattern. However, I really need a generic RDBMS...

Can Hibernate return a collection of result objects OTHER than a List?

Does the Hibernate API support object result sets in the form of a collection other than a List? For example, I have process that runs hundreds of thousands of iterations in order to create some data for a client. This process uses records from a Value table (for example) in order to create this output for each iteration. With a List...

Enumerations in Hibernate

It is often useful to have a field in a DAO whose value comes from a Java enumeration. A typical example is a login DAO where you usually have a field that characterises the user as "NORMAL" or "ADMIN". In Hibernate, I would use the following 2 objects to represent this relationship in a (semi-)typesafe way: class User { String user...

Annotating inherited properties for persistence

Assuming I have a class A as follows: class A{ int id; int getId(){}; void setId(int id){}; } And a class B as follows: @Entity @Table(name="B") class B extends A{ string name; @Column(length=20) string getName(){} void setName(){} } How can I annotate the inherited id field from A so that Hibernate/JPA knows ...

Applying the Hibernate filter attribute to a Bag with a many-to-many relationship

Consider the following Hibernate mapping file: <hibernate-mapping ...> <class name="ContentPackage" table="contentPackages"> <id name="Id" column="id" type="int"><generator class="native" /></id> ... <bag name="Clips" table="contentAudVidLinks"> <key column="fk_contentPackageId"></key> <many-to-many class="Clip" ...