hibernate

Why not to use Spring's OpenEntityManagerInViewFilter

Hi guys, While a lot of posts have been written on the subject of Spring's OpenSession/EntityManagerInViewFilter, I couldn't find any that mentions its flaws. From what I understand, and assuming a typical layered web application architecture using a @Transactional service layer, the filter works as follows: The filter intercepts a se...

Mix HQL and SQL in the same query

Hi All, I'm trying to mix HQL and SQl in the same query. Like using "from ObjectA obj, TABLE_B tbl where obj.someProp = tbl.COLUMN" because my client will need to modify the query, and learning HQL or mapping unmapped tables is out of the question :( If not hibernate, does somebody knows another ORM tool that can accept this? another ...

How does Hibernate find the generic type of a collection in a @OneToMany mapping?

Given a simple entity relationship: @Entity public class Single { @OneToMany public Set<Multiple> multiples; } How does Hibernate find out that the generic type of multiples is Multiple? This information is impossible to find with the standard Reflection API. I'm looking through the source code, but don't really know where to st...

Ready configurations for Spring + Hibernate

Sometimes, it's very tediously to make own configuration, find all libraries, check it ... So, is there any ready typical (template) config for appropriative task? ...

Hibernate mapping for situation, where the the key is also used as many-to-one parameter

I was wondering if there is a way to do Hibernate mapping for the following. My two days spent on this say there isn't. There are two tables, having one to many relationship. +---------------------+ +-----------------+ | versioned_entity | | basic_entity | +---------------------+ +-----------------+ | fk_BasicEn...

LazyInitializationException while unit-testing Hibernate entity classes for use in Spring, using TestNG

Hi guys, In my Spring configuration, I've asked that the session should remain open in my views: <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"> <property name="sessionFactory" ref="sessionFactory"/> <property name="flushMode" value="0" /> </bean> ...

Throwing specific error messages in PLSQL Oracle...catching in hibernate?

Is it possible to throw a specific error message in a PL/SQL oracle stored procedure and catch it in Hibernate when it gets invoked? ...

How to determine optimum prepared statement cache size when using Hibernate

AFAIK, Hibernate transforms all sql to prepared statement form before issuing it to the database. When tuning the application, the size of prepared statement cache can be an important factor. How to determine the optimum value when using Hibernate, given that it creates prepared statements “under the hood”. ...

Hibernate Immutable Value Object

customer = // get customer from the current hibernate session // customer has a discount with database id of 1 Everything is fine until here. But if I call: discount = SpecialDiscount.create("10%"); customer.setDiscountTo(discount); session.save(customer); // customer has a discount with database id of 2 now How hibernate can updat...

Hibernate: Event Listener or Interceptor, what are the pros/cons in practice?

I will be implementing a feature to update an id in a table after Hibernate does my deletes. But I want to get some feedback on which approach is better. Also the table I am updating the value in, Hibernate doesn't know about it so I would have to do a straight jdbc update -- is that even possible. ...

Hibernate QueryException couldn't resolve property

I have this .hbm.xml file : Evenement.hbm.xml : <hibernate-mapping package="com.af.evenement"> <class name="Evenement" table="TB_EVENEMENT"> <id name="id" type="string" column="CODE_EVENEMENT"> <generator class="assigned" /> </id> <set name="causesAnnexes"> <...

Hibernate with ZK

Does anyone have any experience on getting Hibernate working with ZK? Thanks Edit: Sorry to clarify what I am looking for: I am looking for anyone that has experience doing this, maybe they can clarify is it easy? I have never used Hibernate before. In addition can anyone provide any resources focussed around this issue? ...

Hibernate case-insensitive utf-8/unicode collation that works on multiple DBMS

I'm looking for Hibernate annotation or .hbm.xml that allows me to specify a table column as case-insensitive string working in unicode/utf-8/locale-independent manner that works on multiple database engines. Is there any such thing? So that I can do query using Restrictions.eq("column_name", "search_string") efficiently. ...

hibernate OneToOne PrimaryKeyJoinColumn gives ClassCastException while saving the object

java.lang.ClassCastException: org.hibernate.type.SerializableType incompatible with org.hibernate.type.EntityType at org.hibernate.id.ForeignGenerator.generate(ForeignGenerator.java:74) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122) at org.hibernate.event.def.Defau...

compute child table values in formula field of hiberntate

I am facing a problem in hibernate property formula field. Not able to combine both table columns. shift_id column belongs to parent table of job_card and duration column belongs to child table of job_card_idle_time. but it consider both columns are belongs to parent table of job_card. <property name="utilization" f...

HQL Join Fetch question: aliasing association

Given I have an object A with a collection B and I want to get A with all B that fit a certain criteria "from A a left join fetch a.bs c where a.id = ? and c.id = ?" The above certainly won't work so there must be another fetch after I alias c so would this be correct "from A a left join fetch a.bs c join fetch c.id = ? where a.id = ...

Hibernate Inheritance Mapping and Attribute Override

The system I'm working on has a domain object named Order which inherits from AbstractPersistentObject. Now I need to add another domain object named ExternalOrder which has some of the properties of Order but not all. I would like these two objects to be treated polimorphically in certain places. Hence I'm thinking of implementing inher...

JPA+Hibernate: Change of createNativeQuery() + getResultList() behaviour?

What I am going to describe is a bit of legacy code. So there is a lot of stuff I cannot touch/change. This pseudo-code runs well the in Jboss 4.0.3, big_messy_sql = "select t1.f1 as somealias, t2.f2 as somehthingelse from obj1 t1, obj2 t2 where crazy_conditions...."; Query query = entityManager.createNativeQuery(big_messy_sql); L...

Is it valid for Hibernate list() to return duplicates?

Is anyone aware of the validity of Hibernate's Criteria.list() and Query.list() methods returning multiple occurrences of the same entity? Occasionally I find when using the Criteria API, that changing the default fetch strategy in my class mapping definition (from "select" to "join") can sometimes affect how many references to the same...

Hibernate - How to use an Enumeration as Map's Key

Hi all, My entity defines a field like Map<String, String> props; I've got this hibernate xml configuration <map name="props" table="PROPS"> <key column="id"/> <index column="name" type="string"/> <element column="value" type="string"/> </map> Now I want my Map to be an EnumMap like Map<MyEnum, String> prop...