hibernate

nHibernate Share References?

I'm getting a "Found shared references to a collection" exception when saving an object. Does anyone know what this means? ...

Output SQL query results to flat-file with Java

Is there an easy or straightforward way in Java to output the results of a DB Query to a file (either csv, tab, etc). Perhaps even in Hibernate? I know that a query results can be dumped to a flat file on the DB Server. I am looking for a way that an application can run a query and get those results into a file. I realize one option ...

How to reuse a Criteria object with hibernate?

I'm trying to do query result pagination with hibernate and displaytag, and Hibernate DetachedCriteria objects are doing their best to stand in the way. Let me explain... The easiest way to do pagination with displaytag seems to be implementing the PaginatedList interface that has, among others, the following methods: /* Gets the total...

How do I map a hibernate Timestamp to a MySQL BIGINT?

I am using Hibernate 3.x, MySQL 4.1.20 with Java 1.6. I am mapping a Hibernate Timestamp to a MySQL TIMESTAMP. So far so good. The problem is that MySQL stores the TIMESTAMP in seconds and discards the milliseconds and I now need millisecond precision. I figure I can use a BIGINT instead of TIMESTAMP in my table and convert the types i...

Use type of object in HQL where clause

In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down the result to certain types of channel specifications. E.g. (i...

Hibernate Locking DB2 File

We're using Hibernate in our Spring web app to do reads, as well as DML with a DB2 database. This problem only occurs during an update. If we blow away the lock on the DB2 side, it appears that any updates are not syncing with the database (even though I do session.flush() and session.clear() after an update is performed). This really...

Spring, Hibernate & JPA: Calling persist on entitymanager does not seem to commit to database

I'm trying to setup Spring using Hibernate and JPA, but when trying to persist an object, nothing seems to be added to the database. Am using the following: <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="url" value="${jdbc.url}"/> <property name="driverClassName" value="${jdbc.driverClass...

(N)Hibernate: core/master mappings with relationships

I am starting a job with a mid size company working mostly on writing custom apps that interact with their ERP system. This is my first time doing this sort of work, so the ERP concept is new to me and I am learning it piece meal. I have only written two apps so far and have learned the database model as I went and only as much as I n...

ORA-04091: table [blah] is mutating, trigger/function may not see it

I recently started working on a large complex application, and I've just been assigned a bug due to this error: ORA-04091: table SCMA.TBL1 is mutating, trigger/function may not see it ORA-06512: at "SCMA.TRG_T1_TBL1_COL1", line 4 ORA-04088: error during execution of trigger 'SCMA.TRG_T1_TBL1_COL1' The trigger in question looks like ...

hibernate column name issues

@Column(name="DateOfBirth") private Date dateOfBirth; I specifically need the above code to create a column named "DateOfBirth," instead Hibernate gives me a column named date_of_birth. How can I change this? Is there a web.xml property? I came across DefaultNamingStrategy and ImprovedNamingStrategy, but not sure how to specify one ...

Combo boxes with Hibernate

Im searching for the best way to mantain combo box values within a Mysql Database accessed by Hibernate objects. Currently we have the following table: CREATE TABLE COMBO_VALUES( KEY VARCHAR(5) NOT NULL, COMBO_TYPE VARCHAR(20) NOT NULL, VALUE VARCHAR(100) NOT NULL PRIMARY KEY(KEY,COMBO_TYPE) ); INSERT INTO COMBO_VALUES VALU...

How do I dynamically replace the class loader for an Eclipse plug-in?

I am developing an Eclipse plug-in that fits a client-server model. Its a commercial project so we cannot re-distribute the JDBC drivers for the various databases we support with the plug-in. So I developed a preference page to allow the user locate the jars and have a simple discovery mechanism that iterates through the classes in the ...

How to map many-to-many List in Hibernate with a Link Table

I would like to map a many-to-many in Hibernate using a link table. I have two classes, Parent and Child class, for example: public class Parent{ private List<Child> _children; //...getters and setters } I use a link table (link_table) with three columns link_id, parent_id, and child_id. The database is SQL server and id types are u...

Database perform advice when batch importing large datasets

I'm building a database web application using Java and Hibernate's JPA implementation. The application tracks objects. It also has to batch import objects from a legacy source. For example, let's say we're tracking people. The database has tables called Person and Address. There are corresponding JPA entity and DAO classes. On top of t...

How does Hibernate create proxies of concrete classes?

To the best of my knowledge, creating a dynamic Java proxy requires that one have an interface to work against for the proxy. Yet, Hibernate seems to manage its dynamic proxy generation without requiring that one write interfaces for entity classes. How does it do this? The only clue from the Hibernate documentation refers to the fact th...

Storing Dates in Oracle via Hibernate

Hi, I'm storing a simple java.util.date in an Oracle XE database via hibernate. When testing with JUnit if I can retrieve the correct value, I get an error like this: junit.framework.AssertionFailedError: expected:<Sun Dec 28 11:20:27 CET 2008> but was:<2008-12-28 11:20:27.0> The value is stored in an Oracle Date column (which...

Hibernate: Mapping User-Friends relation in Social Networks

It's quite some time that I'm trying to figure out this problem and from googling around many people have similar problems. I'm trying to model a User in a Social Network, using Hibernate, and what is more basic to a social network than to map a friendship relation? Every user in the system should have a list of it's friends and I thoug...

How to reference a Grails domain class fields from outside of the Grails controller and view?

I have the domain classes: class Child { static hasMany = [ toys : Toy ] String name Set toys } class Toy { static belongsTo = [ owner : Child ] String name } In my JSP I reference a child by: child = Child.findByName("Joe") or child = Child.findById(123) But when I attempt to access its fields: child.getTo...

Grails eager fetch doesn't retrieve all data

I have the domain classes: class Person { static hasMany = [ items: Item ] static fetchMode = [ items: 'eager' ] String name Set items } class Item { static belongsTo = [ owner: Person ] String name } If I leave static fetchMode = [ items: 'eager' ] in place, then calling getItems() only returns about 10% of t...

How to programmatically bring a laptop into Sleep mode.

What API or tools can I use to query the capabilities of the system and choose the most appropriate on for putting the PC to Sleep, Hibernate or shutdown mode? Thanks for any pointers. ...