hibernate

Hibernate: how to call a stored function returning a varchar?

I am trying to call a legacy stored function in an Oracle9i DB from Java using Hibernate. The function is declared like this: create or replace FUNCTION Transferlocation_Fix (mnemonic_code IN VARCHAR2) RETURN VARCHAR2 After several failed tries and extensive googling, I found this thread on the Hibernate forums which suggested a ma...

question on database query using hibernate in java with annotations

Hello, simple question regarding HQL(Hibernate query language) so i have user class , that can hold a list of Projects, how do i take this out of the database depending on a username, this is how i take out my user String username = "stephen"; YFUser user = (YFUser) session.createQuery( "select u FROM YFUser u where u.usernam...

executing stored procedure from Spring-Hibernate using Annotations

I'm trying to execute a simple stored procedure with Spring/Hibernate using Annotations. Here are my code snippets: DAO class: public class UserDAO extends HibernateDaoSupport { public List selectUsers(final String eid){ return (List) getHibernateTemplate().execute(new HibernateCallback() { p...

Data dump of Hibernate-based application

Is there some tool for do dump data to some format. May be XML, JSON, CSV etc for using it in other application(may be with other DB engine) ...

Mapping issue with multi-field primary keys using hibernate/JPA annotations

Hi all, I'm stuck with a database which is using multi-field primary keys. I have a situation where I have a master and details table, where the details table's primary key contains fields which are also the foreign key's the the master table. Like this: Master primary key fields: master_pk_1 Details primary key fields: maste...

How to discover getters and setters on hibernate objects

I need to find a way of taking a hibernate object and discovering at runtime all of the getter methods that relate to persistable fields. I'm using annotations in the classes but have previously had difficulties working with them (I ran into a 2 year old bug the java developers still haven't fixed). Does anyone know how I can do this pl...

Concurency problem with Isolation - read-committed

I have to write a simple demo for amount withdrawl from a joint Bank amount .Andy and Jen holds a joint bank account with number 123 . Suppose they have 100$ in their account .Jen and Andy are operating their account at the same time and both are trying to withdraw 90$ at the time being .My transaction Isolation is set to read-committed...

Hibernate object equality checking

As far as I understand(correct me if I am wrong) Hibernate uses object reference to check the object equality. When Hibernate identifies that there are more than one objects attached to same DB record, it throws following exception. "a different object with the same identifier value was already associated with the session" My question...

HQL make query searching by date (Java+NetBeans)

Hi all I have the following issue. I have a table of reserves in my MySQL DB, the date columns is defined DATETIME. I need to make a query using hibernate to find all reserves in one day no matter the hour, just that its the same year month and date, and I'm doing this public List<Reserve> bringAllResByDate(Date date){ em = emf.createE...

How do I insert the null value in a Boolean attribute when using Hibernate?

I have a class with a Boolean attribute. When I instantiate and persist this class, the Boolean attribute is stored with the "false" value instead of the expectable "null". How can I set a Boolean attribute to "Null"? ...

servlet and jsp sending query result following MVC framework

Hi every one, in order to separate java code and html code and be more faithful to MVC framework i am coding like that; in the servlet i put the following: net.sf.hibernate.Session s = null; net.sf.hibernate.Transaction tx; try { s= HibernateUtil.currentSession(); tx=s.beginTransaction(); Query query =...

Hibernate Bi-Directional ManyToMany Updates with Second Level cache

I have a bidirectional many-to-many class: public class A{ @ManyToMany(mappedBy="listA") private List<B> listB; } public class B{ @ManyToMany private List<A> listA; } Now I save a listA into B: b.setListA(listA); This all works fine until I turn on second-level caching on the collection a.ListB. Now, when I update the list in B...

Help with Hibernate mapping

Hi i have the following classes public class RSS { private Integer id; private String title; private String description; private String link; private Date dateCreated; private Collection rssItems; private String url; private String language; private String rating; private Date pubDate; priv...

Hibernate Tools - DAO generation

Hello, I am using the eclipse hibernate tools plug-in to reverse engineer my database. I spent my whole day looking for how to force the DAO generator to use HQL/Criteria with the session factory, transaction, etc. Right now, if I have the table TABLE in my database, I obtain the DAO class TableHome. This class uses the persistence Enti...

jboss envers for versioning?

I have entities that required versioning support and from time to time, i will need to retrieve old version of the entity . should i just use options available 1. http://stackoverflow.com/questions/762405/database-data-versioning 2. jboss envers (can this be used on any web server,tomcat,jetty, appengine) ? 3. any similar library like...

JPA 2.0 @OrderColumn annotation in Hibernate 3.5

I'm trynig to use @OrderColumn annotation with Hibernate 3.5 @OneToMany(mappedBy = "parent",fetch=FetchType.EAGER, cascade=CascadeType.ALL) @OrderColumn(name = "pos") private List<Children> childrenCollection; When retrieving data everyting works fine. But I can't make it to reorded elements in List and save new order to database. ...

Hibernate statistics does not seem to give right data.

I've tried to use Hibernate Statistics to collect information like "query count, transactions, etc." to monitor my app's performance parameters. With Query count, on select queries, it gives right numbers, but the queries fired for update and delete are not reflected on the query count. Would like to know if anyone faced this issue.. a...

[hibernate - jpa] @OneToOne annotoation problem (i think...)

Hi all, im new in hibernate and JPA and i have some problems with annotations. My target is to create this table in db (PERSON_TABLE with personal-details) ID ADDRESS NAME SURNAME MUNICIPALITY_ID First of all, i have a MUNICIPALITY table in db containing all municipality of my country. I mapped this table in this ENTI...

Hibernate Second Level Caching inverse collection

Hi, Is it possible to second level cache an inverse collection? Whenever I add objects to the other end (and also to the inverse end, although not really sure what the point is as its not persisted), the version doesnt change on the inverse end and hibernate rereads the old collection from the cache the next time I ask for it. Is there a...

jpa join query on a subclass

I have the following relationships in JPA (hibernate). Object X has two subclasses, Y and Z. Object A has a manyToOne relationship to object X. (Note, this is a one-sided relationship so object X cannot see object A). Now, I want to get the max value of a column in object A, but only where the relationship is of a specific subtype, ie...