hibernate

Hibernate, C3P0, Mysql Connection Pooling

Hi all, I recently switched from Apache DBCP connection pooling to C3P0 and have gone through my logs to see that there are connection timeout issues. I haven't had this in the past with DBCP and Tomcat, so I'm wondering if it is a configuration issue or driver issue. Whenever I load a page after the server has been idle for a while, ...

Blob in Java/Hibernate/sql-server 2005

Hi, I'm trying to insert an HTML blob into our sql-server2005 database. i've been using the data-type [text] for the field the blob will eventually live in. i've also put a '@Lob' annotation on the field in the domain model. The problem comes in when the HTML blob I'm attempting to store is larger than 65536 characters. Its seems that...

Hibernate3: Self-Referencing Objects

Need some help on understanding how to do this; I'm going to be running recursive 'find' on a file system and I want to keep the information in a single DB table - with a self-referencing hierarchial structure: This is my DB Table structure I want to populate. DirObject Table: id int NOT NULL, name varchar(255) NOT NULL, par...

Why are people continuing to use xml mapping files instead of annotations?

I've observed the strange fact (based on the questions in the hibernate tag) that people are still actively using xml files instead of annotations to specify their ORM (Hibernate/JPA) mappings. There are a few cases, where this is necessary: you are using classes that are provided, and you want to map them. you are writing an API, who...

Join tables with additional fields

We started with a fairly standard relationship between a Project entity and a ProjectStatus entity via a join table. The class declarations (with annotations) look like this. @Entity @Table(name="PROJECT") public class Project { @Id @Column(name = "PROJECT_ID") private Long id; @ManyToOne(fetch=FetchType.EAGER, cascad...

How to create Tinyint Field in Hibernate annotation

hi all, I have problem in creating tinyint field in MySQL database using Hibernate. I used to write the Entity class like this @Entity @Table(name="tablename") public class MyEntity { private int id; @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id") public int getId() { return id; } public void setId(int id) { ...

JPA 2 in Jboss and criteria api

Is there a working JPA 2 implementation for JBoss server? Or maybe there is some additional extension that provides JPA 2's criteria api equivalent? ...

database sharing between two servers

My current set up is a single dedicated server with Java, hibernate app running on tomcat, apache http server, MYSQL. I need to get a second server to share the load, but using the same database from the first server. The backend processing(excluding db transaction) is time consuming, hence the second server for backend processing)....

Setting createdBy and updatedBy in JPA entities automatically

Hi everyone, I'm working on a JPA (Hibernate implementation of), Spring and Stripes web app. I have a number of JPA entities that have the following fields in common for both audit and query purposes: createdBy - the user ID of the person who created the entity. createdOn - the date the entity was created updatedBy - the user ID of the...

Hibernate mapping

I got a table with a PK and a value "country", all my labels are definied in another table which has composite-ids. Does anyone has an example for me how I can map my country value to the correct label in the other table? mappings are bound on PK, if I'm not wrong. <class name="hibernate.P1" table="P1"> <id name="id" type="int...

Hibernate implicit entity restrictions

Is any way to add implicit restriction to entity in HQL? For example when we query list with hql "from Client" we need select only thouse clients, that have some particular system id. System id itself depends on user session. So we need this query to be actually converted to "from Client where systemId=:systemId" although we didn't speci...

Hibernate one-to-one entity association with shared PK between 3 classes

I want a unidirectional one-to-one relationship between objects of 3 java classes: Person to Heart, and Person to Liver. I want the objects to share the same PK i.e. every person has a corresponding heart and liver, where person.person_id = heart.heart_id = liver.liver_id. I do not want to merge the 3 tables into 1 because each has loads...

Using hibernate tools to reverse engineer pojos from Postgres

Hi - I am trying to reverse engineer pojos (using hibernate tools plugin v3.2.4x in eclipse 3.4.2) from a database that I have created in Postgres but my tables are being ignored. It works if I specify 'public' as the value for the 'hibernate.default_schema' property in my hibernate.cfg.xml file but if I try to specify a different schema...

Hibernate query: find equal objects

Hi, I have a Hibernate class which has a reasonably complicated implementation of equals(). Is it possible to write a query that returns all instances of this class that have at least one other equal object, where equality is defined by the implementation of equals()? Update Evidently this is not possible. As an alternative, is it poss...

How to delete multiple db entities with Nhibernate?

What is the best practice for this problem? Is there any batching features built-in? Sample code: using (ITransaction transaction = _session.BeginTransaction()) { _session.Delete("FROM myObject o WHERE o.Id = IN(1,2,...99999)"); transaction.Commit(); } Thanks in advance. ...

Hibernate session problem for transactions.

Hi all, I am new to hibernate and trying integrate hibernate with an existing spring based application. I configured session factory and transaction manager, transaction proxy template. I am also using Quartz scheduler in this application. When I run the application, I am getting the following exception. ERROR au.com.michaelpage.cts...

Hibernate: Query without SQL-strings?

Hello everyone! Is it possible (and if yes, is it advisable) to do queries of Hibernate-mapped data without using SQL-strings, but some OOP way instead? ...

Can someone provide a bare bones Ant build script for Hibernate?

Most Hibernate tutorials use Maven for handling the build, but I'm looking for a basic configuration using Ant instead. I've reviewed this some: https://www.hibernate.org/hib_docs/tools/reference/en/html/ant.html However, it seems like it covers way more in an introductory tutorial than I need. I really want to get started w/ some simp...

How to map a database query into an Object [in Java]?

I have a query that joins 5 tables. Then I fill my hand-made object with the column values that I need. What are solutions here that are wide-common to solve that problem using specific tools ? are there such tools? I'm only beginning to learn Hibernate, so my question would be: is Hibernate the right decision for this problem? Hibern...

Grails optimistic locking strange behaviour

I've been trying to make GORM throw an optimistic locking error in an integration test. It has been said before that it is not possible to test for concurrent update errors without resorting to multiple threads, but even so I find the behaviour of my test case surprising: void testOptimisticLocking() { new Widget(foo:"bar").save(flus...