hibernate

using AbstractTransactionalDataSourceSpringContextTests with Hibernate & DbUnit - inserted data not found

All, I'm attempting to write a unit test for a Dao that uses Hibernate. I'm also using Spring, so I'm trying to extend AbstractTransactionalDataSourceSpringContextTests and also use DBUnit to insert data into the database before each test in the onSetUpInTransaction method. From my logs, I can see that DbUnit is able to successfull...

MyEcplise | Remove hibernate reverse engineering

How do I remove the generated hibernate reverse engineering capabilities, deleting POJOS and .hbm.xml files from the source doesn't work because that won't allow to re-create the reverse engineering capabilities (When I click it just won't prompt the wizard). I want to do this because the current reverse engineering capabilities does not...

Difference Hibernate 3.5 / JPA 2.0

So far, I always prefered to use Hibernate directly rather than JPA 1.0, because JPA was lacking some of the important features I needed and Hibernate provided: Criteria API, second level cache, unidirectional OneToMany and a few others. Now, with the advent of JPA 2.0 and all the new features that come with it and that were initially m...

Hibernate: The dialect was not set. Set the property hibernate.dialect.

I have the following hibernate.cfg.xml: <hibernate-configuration> <session-factory> <property name="hibernate.format_sql">true</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/EJB</property> <property name="hibernate.connection.driv...

Hibernate Session closed problem!

The function below is the actionListener for a button I have in my web application, I am deleting the old chosen rows from a table in a database and inserting the new ones to the database. public void getSelectedExemptionItems(ActionEvent ae) { Session hibernateSession; Session hibernate2Session; selectedExemptio...

Hibernate JPA - ManyToOne relationship not populated

I'm currently moving a (working) app from using EclipseLink to Hibernate JPA, mostly it's gone quite smoothly, but I'm finding one thing that I can't explain, and also can't think of any good search terms! Basically, I have four entities, with one-to-many relationships forming a chain: EntityA has a list of EntityB's, each of which has...

Storing a Set of Integer values in Sql Server 2005 with nHibernate?

What is the best way to store and map an Entity which contains a set of Integer as one of its attributes? I am using nHibernate over Sql Server 2005. Will creating a CLR Custom Type will help here? If yes how it can be mapped using nHibernate? I should be able to query on the Set. E.g. select myEntity from MyEntities where myEntity.In...

Empty Hibernate cache on demand

I'm writing a soap web service: Jboss + Hibernate + Java. Database on PostrgreSQL. After publishing the webservice, it runs perfectly. For testing purposes I change data on the database by opening pgAdmin, and changing the values on the rows by hand. Now, the problem is, Hibernate is not aware of those changes. Not until I re-publish th...

How to select a partial object including a list with new() syntax in Hibernate

In my Hibernated system, I have a class Picture that has some simple data, a list of Installations and some (huge) binary data. The list of Installations is implemented with a join table, as it's a ManyToMany relation, and it's defined on the Installation side: @Entity public class Picture { @Id private long pictureId; private Str...

A couple of questions about the use of Hibernate and ORM with Oracle

I am thinking of writing a tool that will list all the tables in an oracle database. Clicking on any of the links for each of the table will load the data from that table. Usually i just use plain old jdbc with standard sql queries or stored procedures in the code. This has worked fine for me so far but i am wondering if using hibernat...

Java and Hibernate - HQL aggregate alias

Hi all, I am trying to write a simple HQL query with an aggregate function and getting an error. Please help. I have 3 entities Order, OrderItem and Product with the following relationships: Order --> OrderItem (One to many bi-directional) OrderItem --> Product (Many to one Uni-directional) At a high level, a Customer can place an O...

List Hibernate configuration parametrs

Is there a way to programatically get Hibernate configuration parameter values, if I have access to a SessionFactory object? I would like to list the configuration in a GUI view, for debuging purposes. ...

When should hasMany be used for N:1 relationships in grails domain classes?

In grails, I can implement an N:1 relationship like this: class Parent { hasMany = [children:Child] } class Child { belongsTo = [parent:Parent] } Now (if addTo and removeFrom is always properly used) I can get a Parent's children via parent.children. But I can also do it without hasMany: class Parent { } class Child { belongsTo = ...

Hibernate Many-To-Many HBM Mapping

How would I generate the hbm file for the following scenario? In particular, I'm having trouble modeling the many-to-many relationship's composite key..... Table: Course Primary Key: CourseId Table: Enrollment Primary Key: CourseId, StudentId Table: Fees Primary Key: FeeId Other Columns: Amount, Description Table: Enrollment_Has_Fees...

Hibernate 2nd Level caching doesnt seem to be working

Im currently trying to get hibernate working using the caching provider that comes with hibernate. net.sf.ehcache.hibernate.SingletonEhCacheProvider I have a default cache and a class specific cache enabled in the ecache.xml which is referenced in my hibernate.cfg.xml file. The class/mapping file specific cache is defined to handle u...

How to Stop Hibernate From Trying to Update one-to-many Over Join Table

Ok so I'm having bit of a problem with my Hibernate mappings and getting the desired behavior. Basically what I have is the following Hibernate mapping: <hibernate-mapping> <class name="com.package.Person" table="PERSON" schema="MYSCHEMA" lazy="false"> <id name="personId" column="PERSON_ID" type="java.lang.Long"> ...

Querying on property of a hasMany relationship

I have the following association in a domain I'm working on (not actually pirates unfortunately). A ship has many pirates. I want to be able to find all ships that have a captain and do not have any land lubbers on the crew. class Pirate { String name Rank rank enum Rank { CAPTAIN, DECK_HAND, LAND_LUBBER } } cl...

DisplayTag pagination vs Hibernate Pagination

Hi all, Display Tag provides pagination feature from the given object. Hibernates provides option to fetch only required record per page.In My project we are using both the concept. Display Tag: I need to fetch all the record based on the filter criteria and store it in the Session. Then this displaytag will take care about all paginat...

Hibernate Tools Eclipse Classpath

How do I set the classpath in eclipse which is used by Hibernate Tools? I have tried right-clicking on my project, going to properties, then Java Build Path, then the Libraries tab, and adding the appropriate JARs. However, Hibernate Tools still gives a classNotFound even after I added the JAR using the above process. ...

With Spring Transactions with Hibernate, how can you get 2000+ inserts to not slow down in the same transaction?

I have a curious little problem. I have a service that needs to create 2000 records in the database, minimum on various tables. While it would be nice to have them run in the same transaction, the performance gets to be really bad around 400-600 inserts. For some reason, the inserts go slower and slower. I suppose that Hibernate needs t...