hibernate

JPA+Hibernate - Reconnecting entities from a @OneToMany relationship

Hello everybody. Consider the following simple example: One team has many players and a player may only belong to one team. @Entity public class Team { @OneToMany(cascade = CascadeType.ALL, mappedBy = "team") @Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORP...

Java Spring-Hibernate mapping question?

Say I have domain objects corresponding to Posts and Users. Nevertheless, I have corresponding database tables containing information relevant to "posts" and "users". Currently I have properly set up the mapping in Hibernate so that I can pull the info from the "posts" table and save it as a Post object. However, I then added to my ...

Calling one DAO from another DAO?

Can this ever make sense? Say I need to fetch an object from the DB which has a relation to another object (represented by a foreign key in the DB, and by a composition in my domain object). If in my first DAO I fetch the data for object 1, then call the dao for object 2, and finally (from within the first DAO, call the setter in objec...

Using Restrictions.disjunction over @JoinTable association

This is similar, but not identical, to: http://stackoverflow.com/questions/1528352/hibernate-criteria-query-on-different-properties-of-different-objects I have a SpecChange record, which has a set of ResponsibleIndividuals; these are User records mapped by a hibernate join-table association. I want to create a Criteria query for a Spec...

Hanling exception from the database during a Transaction.

Hi, I have some webservices uses to pertform operations on the database (classic CRUD operations) with Daos which are using hibernate. Let's take a simple example : with Spring annotation for the transaction in my XML: tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" I have this method in my web...

Using the grails Quartz plugin without Hibernate

I am working on a backend Grails application that pulls information periodically from a RESTful service. To do this I installed the Grails Quartz plugin. grails install-plugin quartz I then created a job using grails create-job My which geneates a MyJob file which I configured with a cron trigger static triggers = { cron name...

Constraint error in hibernate

Hi I am new to hibernate. I am having 2 tables, assume table1 and table2 . table2 has composite key and id column of table2 is referencing id column of table1. I have created one to many mapping in hbm file of table1. Wen I try to insert or update using gethibernatetemplate().saveorupdate(object).. I am getting the following excepti...

How to use second level cache for lazy loaded collections in Hibernate?

Let's say I have two entities, Employee and Skill. Every employee has a set of skills. Now when I load the skills lazily through the Employee instances the cache is not used for skills in different instances of Employee. Let's Consider the following data set. Employee - 1 : Java, PHP Employee - 2 : Java, PHP When I load Employee - ...

Where can I find a complete (!) list of all Hibernate events?

Hibernate supports several events through listener interfaces. I could find all interfaces in the API docs. But i couldn't find a complete list of the corresponding event names. Any idea where to look? ...

persistence.xml ignores Hibernate and chooses DataNucleus

Hi, I'm toying around with GWT (dunno if this matters) and Hibernate. I've created a a file persistence.xml in META-INF with (amoung) other configuration the line: org.hibernate.ejb.HibernatePersistence But when I startup the EntityManager it chooses DataNucleus instead of Hibernate (which later fails because it isnt installed (jar are ...

use of insert and update attributes

What is the use of insert and update attribute in property tag in hibernate ? ...

Hibernate Tool for Weblogic 9.2.1

Hi I'm using weblogic workshop 9.2.1 . Is there any hibernate tool available which is supported by weblogic workshop 9.2.1 ? Any help will be highly appreciated. ...

Confusions in hibernate mappings

Hi i am new to hibernate technology and i have few issues. Suppose if there are two tables. For Example: Table1 table1_ID table1_value Table2 table2_ID table2_name If table1_ID is primary key of table1 and (table2_ID and table2_name ) - primary key of table2. table2_ID of Table2 is referencing table1_ID of Table1...

Interacting with the hibernate Session during event calls

Hi all, I want to write a history component that tracks changes to a particular object type and writes history rows based on the difference. Note this is not a general audit system it is specific for one object type. I figure I can hook into the hibernate event model and listen for events that tells me when things have changed, watch ...

Hibernate for ontologies?

Hi, does anybody know of a tool capable of doing for OWL ontologies what Hibernate does for relational databases, that is, from my point of view, abstract away the need to manually code SQL queries to read/write Java objects from/to relational databases and manage the consistency of in-memory objects and their serialized form on the DB. ...

Trouble with Hibernate One Way Associations

I'm trying to implement a Hibernate persistence layer in a Java application and I'm having some trouble with it. I'm encountering a no proxy error every time I attempt to access a simple, one way association. I haven't implemented Hibernate in quite the right way - I am using the thread method of Session control, which they do suggest ...

Hibernate error: executeQuery method cannot be used for update

When I run the following: Session session = null; Transaction tx = null; List<Intake> intakes = null; try{ session = sessionFactory.getCurrentSession(); tx = session.beginTransaction(); intakes = session.createQuery("from Intake i where i.assignedTo=?") .setParameter(0, assignedTo)...

How to use Dynamic Instantiation with ICriteria in Nhibernate?

I know that you can do this easily with HQL using the following syntax: "select new ItemRow(item.id, item.name) from ..." In this example, the ItemRow need not be a persistent class that has its own mapping class. But how can we accomplish the same using ICriteria? ...

JPA/Hibernate DDL generation; CHAR vs. VARCHAR

I have a JPA/Hibernate data model that I am using the Hibernate hbm2ddl tool to generate database DDL. I have some strings that should be CHAR and some that may be VARCHAR in the database. I want to minimize hand editing of the DDL (I realize that some will have to happen). Anyone know how I should go about this? I realize that I can ma...

hibernate and ehcache replication

Hi, I am working on a cache replication solution between nodes Node A - master node => Hibernate + Database + Ehcache as secondary cache Node B - regional node=> Ehcache as prmiary cache. no Hibernate Node B is used only as near-by cache for query. Now I am updating data (Say SudentInfo) in Node A, it gets persisted and cached correc...