hibernate

How can I prevent Hibernate + c3p0 + MySql creating large numbers of sleeping connections?

I'm using GWT with Hibernate, c3p0 and MySQL to produce a web app with a limited audience (max 50 users per day). During testing I found that Hibernate was opening a connection with each session but not closing it, irrespective of use of the close() method. My current configuration is as follows: hibernate.connection.driver_class=com.m...

JPA - disable validation of persistence.xml

I'm taking my first steps with JPA (Hibernate). The overall idea is to connect to a legacy database to do complex queries. I think, hibernate is a great companion for this task, but... ... for a start, I created one bean, the persistence.xml and hibernate.cfg.xml configuration files and some lines of code in a main method, starting with...

How to use reverse engineering in my eclipse

i am using MySql workbench and My Eclipse 8.6. and making a Hibernate-spring program. Is it possible to use reverse engineering feature in my eclipse with MySql work bench in so that DAO and hbm files can be generate like Derby. How can i do this with MySql workbench. this is a URL of using reverse engineering in my eclipse. http://www.m...

How to convert MySQL query into HQL query?

I am new to HQL. This is a mysql Query. I need to convert it into HQL query. How to do that any suggestions please? `SELECT STUDENT.ID, STUDENT.NAME, STUDENT.GRADE_ID, STUDENT.CLASS, GRADE.NAME FROM STUDENT INNER JOIN GRADE ON STUDENT.GRADE_ID = GRADE.GRADE_ID` STUDENT[ID, NAME, GRADE_ID, CLASS] GRADE[GRADE_ID, GRADE_NAME] ...

using utl_match.jaro_winkler_similarity with hibernate in java ?

Hi there, i want a working example for using oracle built in 'utl_match.jaro_winkler_similarity' method which compare two strings based on how much they are matched, i want the example such that it restrict the results of criteria to only which value of (X) match with given text, i tried some kind of statements but it seem to be not wor...

Beginning Hibernate 3.5 - Problems with ant task

I'm trying to work through "Beginning Hibernate 3.5", and I've hit an initial snag. When I run ant exportDDL, I get the following error: exportDDL: [htools] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration [htools] 1. task: hbm2ddl (Generates database schema) [htools] SLF4J: The requested version 1.6 by ...

How to make this tutorial work? Could not determine type for: java.util.List, at table: College, for columns

Now, i am learning hibernate, and started to using it in my project. It is a CRUD application. I used hibernate for all the crud operations. It works for all of them. But, the One-To-Many & Many-To-One, i am tired of trying it. Finally it gives me the below error. org.hibernate.MappingException: Could not determine type for: java.util.L...

How to use reverse engineering in my eclipse

i am using MySql workbench and My Eclipse 8.6. and making a Hibernate-spring program. Is it possible to use reverse engineering feature in my eclipse with MySql workbench in so that DAO and hbm files can be generate like Derby. How can i do this with MySql workbench. this is a URL of using reverse engineering in my eclipse. http://www.my...

Hibernate creates duplicate entries in the database.

I have a database structure which is something like the one described below. "Universe" can contain any number of "Items". "Person" may have a "Box" which refers to one or more of the "Items" in the "Universe" Universe, Items, Person, Box are all database tables. Box is like a join table for the Person and Items. Note: I am using ja...

java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object

Hi, Im running following query it will display error message. How to solve this error. List<Route>routeList=null; List<?> companyList = session.createSQLQuery ("select name " + "from company "+ "where company_id= " + com...

is hibernate's session thread safe

hi, i need to know, whether the hibernate's session is thread safe or not. But obvious a new session is attached to every thread for execution. But my question is if in one thread i have updated some value of an entity, so will that be reflected in other thread during same time execution?... My problem is when i fire update from two thr...

Hibernate and Postgresql - generator class in hibernate mapping file

Hi, The ids in my postgresql database are auto-incremental (there are sequences defined in a database). When creating a hibernate mapping files I set the class generator to increment: <class name="model.Names" schema="public" table="names"> <id name="id" type="int"> <column name="id"/> <generator class="increment"/> ...

JPA 2 + Criteria API + get oldest element in subquery

I have two entities (Dataset and Item), where the first one contains a list of the latter one. @Entity class Dataset { @Id long id; List<Item> items; } @Entity class Item { @Id long id; @Temporal Date date; String someCriteria; } I am now looking for any dataset, which references an item with someCriteria = 'x' as...

Hibernate, many-to-many save causing ConstraintViolationException

Hi all, I have an object (User) which has none or many Tags. Any User can have any number of Tags, so there's a join table, user_tags which has a user_id and tag_id field. In User.hbm.xml, this is mapped as: <set name="Tags" table="user_tags"> <key column="user_id"/> <many-to-many column="tag_id" unique...

JPA empty tables and join tables

Hi there, I know that truncateisn't supported so I do a Delete from table - this works quite good but the join tables aren't cleaned this way. Example: Delete from Product; Delete from Service; both empty, table service_productis still filled. Is there a chance to clean my join tables without raw sql? example entity public class Se...

JSF 2.0 and hibernate adding new objects to a postgresql database

Hi, I'm writing a JSF 2.0 application with Hibernate and Postgresql database. My problem is quite poor understanding on how to handle session with Hibernate when inserting data into more than one table at a time. I have a method savePerson. The method is called as many times as there are addresses submitted by a user but the object Pers...

problem with determining data type of query column in hibernate

I have written below query in hibernate and it is giving me NullPointerException SELECT new com.reddy.ReddyDTO( col1, IF(STRCMP(COL8, 'zero')=0, 'string', col2) ) FROM entity However it is throwing me NPE as it was unable to determine data type for second column as String type. I can see that it was unable to determine a type by loo...

Help needed for JPA/hibernate - problems with creating entity classes

I started creating JPA/hibernate mappings for a legacy database based on Oracle. At one (early...) point I have a many-to-many relation between to tables (FOO, BAR, join table with extra fields: FOO_BAR). So I defined three entities, created an embeddable Id class for the join table, strictly following some examples from a good (?!) book...

Hibernate, mapping of foreign keys that have been generated by a sequence in the parent table

I have a 1:n relation in the database and java objects that represent the relation with hibernate. The primary key of the parent table is generated with a database sequence, the child object uses the primary key of the parent object as foreign key. I create a new parent object including a set of new child objects. Then I try to persist ...

Hibernate Annotations and SQL Server

I'm using Hibernate Annotations and trying to save an object. But when saving object I get: Cannot insert the value NULL into column 'status' The thing is that in my SQL Server 2008 configuration that field is defaulted to '0'. Now I dot not want to manually set the default value in my Java code like status='0', because I think this...