hibernate

hibernate OneToMany List ordering persisting but reversing?!

so I have a persistent entity that has a @OneToMany list of another entity and I need the list order to be able to be edited by the user, which works wonderfully, I can completely re-order the java List in memory and when I save() the object, the order of links in the linking table DOES change... however, it changes to the reverse order ...

Hibernate query for entity based on whether related entity property is null?

I have the following mapping: <class name="Customer"> <!-- actually one-to-one for all intents and purposes--> <many-to-one name="specialProperty" class="SpecialProperty" cascade="all" not-found="ignore" insert="false" update="false" column="id" unique="true"/> </class <class name="SpecialProperty" lazy="false"> <id name="id" ...

Hibernate Annotations, specifying which members of a component to make persistent

I have a Price object consisting of two MonetaryValues where one MonetaryValue consists of an amount and a currency. If I configure the OR-mapping the XML-way, I can do this <component name="baseAmount" lazy="false" class="MonetartyValue"> <property name="amount" column="baseAmount" precision="20" scale="2" not-null="true"...

What is the BEST way to pull data out of the hibernate layer and into another tier?

As my previous posts can attest, I'm retrofitting in-memory, network-cached performance to what was once an entirely hibernated scenario. In doing this, I'm hitting problems where I deal with proxied objects and need to reattach to sessions, but in doing this I also want to maintain transactability. What are the best practices from movin...

Populate envers revision tables with existing data from Hibernate Entities

I'm adding envers to an existing hibernate entities. Everything is working smoothly so far as far as auditing, however querying is a different issue because the revision tables aren’t populated with the existing data. Has anyone else already solved this issue? Maybe you’ve found some way to populate the revision tables with the existing ...

Hibernate in Glassfish - Ejb3Configuration NoClassDefFoundError

I've put the Hibernate libraries in both the Glassfish domain and in the library collection of my project in Netbeans. hibernate-entitymanager.jar contains both HibernatePersistence (the last class in the call stack) and Ejb3Configuration, so I'm rather stumped as to why I get the missing class error for Ejb3Configuration. java.lang.NoC...

Hibernate calls flush on find- causes not-null error

Hi I have a process which updates a tree to the database, and in doing so, performs reads to check for duplicates entities. I'm finding that trying to do a criteria.uniqueResult() midway through this process causes the following error: org.hibernate.PropertyValueException: not-null property references a null or transient value ...

How do I restore a transient field in Hibernate like readResolve() for hibernate serialization?

Is there a way to hook up a callback method to be called when an object is deserialized from Hibernate. Similiar to Java's readResolve() method for Java object serialization? ...

Elegant ways to handle database views on hibernate entities?

One of the main reasons I use Hibernate is that it provides the flexibility to switch to another database without having to rewrite any code. But until now I did not figure out a good way to define additional views on the tables to which my hibernate entities are matched; I am still using simple SQL scripts for that. Is there a more el...

File attachments broken upgrading to grails 1.1.1 from grails 1.1-beta3

This is a rather specific upgrade path, but it's what I'm on. I think I tried going to 1.1 as well, and had the same problem, but not 100% sure. Anyway, I'm on 1.1-beta3 and have implemented a file upload/attachment system as outlined herer: thegioraproject.com/2008/03/26/image-attachments-in-grails-using-imagemagick/ I've got a 'brok...

Asynchronous Search

I am currently working on building a proof of concept search solution for my company using Lucene and Hibernate Search. I have built individual components which work fine. I am now looking at creating a single API that would allow a user to get search results back from different sources (domain + data). What I would like to achieve is so...

List sorting and ordering problem...

So I've resigned myself to not being able to use the order of a List reliably because hibernate reverses it and everyone says don't do it, so I've added a field to my class as position. I have: @Entity class Procedure { ... int procedureId; List tasks; ... } @Entity class Task { ... int taskId; int position; } Now I don't know how ...

Spring + Hibernate Dynamic Mapping

Apologies if this is a repost, I could not find the search terms to locate a similar question. The application that I work on has support for plugins that can be loaded or unloaded at runtime. There are several API hooks that allow these plugins, among other things, to register richer objects then those provided out of the box. When a p...

Using an Entity (and their Primary Key) as another Entity's Id

So, I'm not sure how to ask this question, as it seems like it should be pretty easy to find the answer to this one. I have 3 tables; ContentHeader, ContentType1 and ContentType2. ContentHeader has a primary, auto-increment key. ContentType1 and ContentType2 both maintain foreign keys to ContentHeader's primary key. These foreign keys ...

Hibernate: Delete where record field < getdate()

I'm having trouble figuring out how to delete a set of records when a particular field is less than the date on the sql server without using tables or field names. Since I'm using MSSQL the query would look something like this: DELETE FROM tickets WHERE expires < getdate() How would I go about getting Hibernate to do this? I'm lookin...

JasperReports JRBeanCollectionDataSource still confused...

So I do now have my working and filling reports. The users of my program can now pass objects from the program to a report object and fill it using the JRBeanCollectionDataSource and that does work. However I can't get all the data in the report I want. I am just very confused about this, how the fields that I declare with a name and...

Performance of hibernate Second Level Caching ehcache

We are considering using ehcache (1.6.0-beta5) to enable second level caching of a number of tables which are never modified. We have set up a read-only ehcache region for this table and currently it seems to be working fine. The Hibnerate POJOs stored in the cache are all immutable. One of the developers here raised an issue that the...

JPA+SQLite problem

I'm configuring JPA to work with SQLite db, with hibernate as the provider. I map a single pojo to a table, no fk's,just plain simple for now. I'm using a SQLDialect I found on the internet.I get this stacktrace, when I try to initialize my application: java.sql.SQLException: SQLite supports only TRANSACTION_SERIALIZABLE at org.sql...

How to verify correct operation of Hibernate second level caching in a cluster?

I am wondering how to verify that Hibernate's L2 cache performs correctly. I have an application running on a cluster of JBoss 5 instances with JBoss Cache. Load testing would answer the question of performance. But how to make sure that cluster related issues like the cache invalidation between nodes works like it should be? ...

JPA: How do I specify the table name corresponding to a class at runtime?

(note: I'm quite familiar with Java, but not with Hibernate or JPA - yet :) ) I want to write an application which talks to a DB2/400 database through JPA and I have now that I can get all entries in the table and list them to System.out (used MyEclipse to reverse engineer). I understand that the @Table annotation results in the name...