hibernate

How to direct hibernate logger statements in different log files for differnet applications using jboss-log4j.xml file

Hi, I am using JBOSS 4.2.2 server to deploy multiple web applications. Each application uses Hibernate and for each application there are saperate log files and saparate appendar. Now for Hibernate logging statements of one application should go in log file of that particular application. Does anybody has idea how to configure log4j.xml ...

Going transactionless with Hibernate

Is there a way to pick-and-choose updates that Hibernate will wrap with a transaction? Inspired by EBay's drive to be transactionless whenever possible, I know of many updates in my application that don't need to be ACID writes. For example, there's an update that consists of a user id and an id for another table. Only one user can in...

Hibernate implementation. Are we paying the reflection penalty?

Long time ago, I was creating a mini ORM using reflection. While reading about reflection I got a similar answer like this: Java Reflection Performance Which makes completely sense and I quit my mini orm and sharpen my CTRL+C, CTRL+V keys ( the lib was intended to avoid having to rewrite again and again the same snippets for differen...

What's the difference between different mapping types in Hibernate?

I'm a newbie in Database design and in Hibernate too. I started reading the documentation for Hibernate. It talked about "Collection Mapping", "Association Mapping" and "Component Mapping". I am not understanding the difference between them and not sure about when to use what in one-to-many/many-to-one/many-to-many relationships. To me, ...

Hibernate: Removing item from a List does not persist

I am having trouble when removing an item from a list. The list is defined in a superclass, but the Hibernate annotations are applied to property accessors in a subclass. There are two methods in the superclass that manipulate the list. The "add" method works fine, but the "remove" does not persist changes. I have checked my Cascade sett...

Where is that best reference to compare Hibernate and Active Record?

I like Active Record but many say it's bad in performance compared to Hibernate. There should be some good article out there but google can't help me. ...

Mapping items-itemtags-tags tables with nhibernate

Lets say i have this database design: Items Id Name Desc ItemTags ItemId TagId Tags Id Tag And i want to map it to the following class class Item int Id string Name string Desc IList<string> Tags Please note that I don't want to declare class Tag, i just want the Item class to have list of strings that repre...

How to eagerly fetch a single "default" entity from a collection in EJB3/JPA

I have a Person entity with multiple phone numbers. @OneToMany(mappedBy="person", cascade=CascadeType.ALL) public Set<PhoneNumberOfPerson> getPhoneNumbers() { return phoneNumbers; } Now I would like to implement a "get default phone number" method for Person that is eagerly fetched. This default phone number is one of the phone ...

How to get SQL from Hibernate Criteria API (*not* for logging)

Hi, is there an easy way to get the (to-be-generated) sql from a Hibernate Criteria? Ideally I would have something like: Criteria criteria = session.createCriteria(Operator.class); ... build up the criteria ... ... and then do something like ... String sql = criteria.toSql() (But this of course does not exist) The idea would then...

Cascading Deletes/Updates using JPA or Inside of Database?

Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it? Will this effect the ability to query for the data if cascades are inside of the DBMS? I am using HSQLDB if that matters. ...

Hibernate : Foreign key constraint violation problem

I have a com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException in my code (using Hibernate and Spring) and I can't figure why. My entities are Corpus and Semspace and there's a many-to-one relation from Semspace to Corpus as defined in my hibernate mapping configuration : <class name="xxx.entities.Semspace" table="Semspac...

Nested JPQL queries in hibernate, are they creating nested objects?

Was thinking about a scenario, suppose two entities, Customer and Order. Suppose I want to see all distinct customers who fulfills a certain criteria, who has one or more orders fulfilling a criteria. If I use something like: Select distinct cust from Customer cust join cust.orders order where order.x = 'y' and cust.z = 1 The above ...

How to limit user access at database level in Hibernate

The App I need to implement a web app that will be used by different users. Each user has different privileges on various tables, e.g. User A can see fields 'name' and 'address' from the table Student User B can see fields 'name' and 'phone number', but not 'address' from the table Student User C can see and modify all fields me...

Recording test data in Hibernate

I have an automated test framework for testing hardware widgets. Right now only pass/fail results of test cases are stored into a relational database using hibernate. I'd like to change this so that various characteristics of the test are stored in the database. (e.g. how many gerbils are running inside the widget, the inputs to various ...

Fixing warnings from Hibernate

I am currently working on a Hibernate project. My current development setup has a rather long debug printout on startup, from alot of hibernate warnings. I would like to clean this up. 2009-02-18 09:14:19 org.hibernate.util.JDBCExceptionReporter logWarnings WARNING: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Change...

How to do ORM for this situation?

I have the two following tables (SQL Server): **IndexValues** IdIndexValue int (PK) Value varchar(2000) IdIndex int (FK for Table Indexes) IdDocument int (FK for Table Documents) **IndexValuesLists** IdIndexValueList int (PK) IdIndexValue int (PK with IdIndexValueList, FK for Table Indexes) Explaining a little, the second table grou...

Why can't I create child objects in Hibernate/NHibernate - tricky mapping problem

I think I have tried every thing to get this to work but to no avail. Any hints/help much appreciated. The following parent-children relationship causes the following error on creation of the parent. could not insert: [Kanpeki.Domain.CalEvtCatergory][SQL: INSERT INTO tb_calEvent_catergory (catergoryID, parentID, catergoryType, catergor...

Hibernate - Declariing A Transient object in a pojo

I have a pojo that is object A , of table TableA TableA (int a1,int a2). To fill the table I run a query that returns (int a1, int a2, boolean b3) (and runs multiple data checks) b3 is not valid in TableA , but I still want to use the same pojo for both (it's a very big pojo , and it will be a major code duplication to have one just ...

Ehcache / Hibernate and RMI replication with large number of entities

Hi All, I'm currently investigating how to use the RMI distribution option in ehcache. I've configured properly ehcache.xml and replication seems to work fine. However I've 2 questions: -> It seems ehcache/ hibernate creates 1 cache per Entity. This is fine, however when replication is in place it create 1 thread / cache to replicate...

Hibernate HQL Query : How to set a Collection as a named parameter of a Query?

Given the following HQL Query: FROM Foo WHERE Id = :id AND Bar IN (:barList) I set :id using the Query objects' setInteger() method. I would like to set :barList using a List of objects, but looking at the Hibernate documentation and list of methods I cannot see an obvious choice of which to use. Any ideas? ...