hibernate

server is not reading the updated data from database

Describing .... our client updates the database. Then the Hibernate database updated, server should read the updated value from database at that moment. But its not happening. To read the updated value from the database, I have to restart the server. Then I see the updated values. What is happenning? ...

Hibernate annotations @ManyToMany

Hi, I created tables in MySQL: role tabel , object_label and role_object_label (links table) I defined @ManyToMany and I gets exception. what the problem in my code? @Entity @Table(name = "object_label") public class ObjectLabel implements Serializable { private static final long serialVersionUID = 3475812350796110403L; priv...

Persisting OneToMany relationship only persists first object in set?

Been messing around with Hibernate and PostgreSQL trying to get it to work as expected. But for some reason when I try to persist an object with a @OneToMany relationship with more than one item in the set all but the first item seem to be ignored. I've tried this via local and remote interfaces but get the same results each time. No ex...

Is it possible to dynamically define column names in Hibernate / JPA?

So i have this existing DB schema with a number of tables that i want to model with JPA/Hibernate. Each table has the same group of 30 additional columns ( to allow for runtime expansion of the number of fields recorded). CREATE TABLE XX ( "ID" VARCHAR2(100 BYTE) NOT NULL ENABLE, "USER_LABEL" VARCHAR2(256 BYTE),...

How to setup intellij-idea to understands table names in hibernate XML files.

I'm using Intellij 9 and Hibernate. Everything works fine, however Intellij does not detect table names in *.hbm.xml files. I've setup hibernate facet and everything else is recognized by intellij (links between hbm.xml files and corresponding classes are working). Just the table name and column name is not get resolved by Intellij. What...

launch script hql or sql on hibernate start

I remember a function that permits to execute hql or sql script during hibernate startup. Someone remember command syntax? The sql script should be locate in meta-inf with a specific name... ...

Network latency under Hibernate/c3p0/MySQL.

I'm connecting to a MySQL (InnoDB) database over a connection with fairly high latency (~80ms) but relatively high bandwidth. I've noticed that query times vary dramatically depending on how the query is issued. In the following examples I'm performing a query for a single, small row by primary key. The query times are: Command line...

Sample Hibernate Application for learning

Hi, Can any one share some information about the sample application using hibernate for learning. Basically I am looking for an application that allows me to do basic database operation from the client page. Thanks, Kamal ...

How to turn on read-only in Hibernate?

I am using Spring to create the SessionFactory: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" p:dataSource-ref="dataSource"> <property name="mappingResources"> <list> <value>META-INF/mapping/domain-objects.xml</value> </list> </property> <pr...

hibernate using annotations or using hibernate configuration files.

I have seen many tutorials where the hibernate is implemented using annotations (basically hibernate annotations or JPA annotations). There are tutorial which mainly focuses on using the hibernate configuration files(hbm.xml files). No use of annotations at all. Now I am little bit confused, which one is better approach ? ...

Hibernate sequence generates non-continous values

I am using a hibernate sequencegenerator to auto-generate unique values for my primary key column.The sample code is given below. @Entity @Table(name = "REQUEST") @javax.persistence.SequenceGenerator(name = "REQ_SEQ", sequenceName = "REQUEST_SEQ") public class Request { /** * Unique id for this request */ @Id @GeneratedValue(strategy ...

What's a good alternative, general name to the HibernateUtil class?

Hi, I have a HibernateUtil class which is the standard by the book (Hibernate in action) class. It gets a session, flushes and closes it. begins,commits and rollbacks transactions and build the sessionFactory. Currently, by mistake, this is called HibernateSessionFactory in our package. I want to refactor it to a more appropriate name bu...

Web application request filter

I am using Turbine 2.3.2 with Hibernate 3. My problem is that the Hibernate session is not active when my (Velocity 1.6.4) template is executed, and I am accessing data from the database for which Hibernate needs lazy initialization. Therefore I get a LazyInitializationException - no Session error. Since I want my Hibernate session to ...

Hibernate different type pojo mapping

Hello, I have a problem with a mapping for this structure that i designed public abstract class A<T> { private int discriminator_value = -1; private T value; //... } public class One extends A<String> { public One(){ setDiscriminatorValue(1); } //... } public class Two extends A<BigDecimal> { public Two(){ setDiscrimina...

Hibernate annotations

Hi, I created a table in MySQL: 'object_label' with columns 'id' and 'name'. I inserted values to this table. In java I created new class -'ObjectLabel': import javax.persistence.*; @Entity @Table(name = "object_label") public class ObjectLabel implements Serializable { private static final long serialVersionUID =...

How to stop session to save onsaved objects during query execution ?

I have problem with session and query execution, please see code below. class A implements Lifecycle{ public boolean onUpdate(Session session){ Query test=session.createQuery("select * from Unknown"); List list=test.list(); B b=new B(); session.save(b); } } class B{ C c; public B(){ ...

Hibernate joined-subclass deadlocks with MSSQL

I'm using Hibernate with Joined-SubClasses to Map a class hierarchy to a database. Unfortunately this causes deadlocks when an object is updated while a different thread is trying to load the same object. With objects that are mapped to a single table this is no problem. This seems to be caused the way MSSQL acquires locks on the table...

hibernate criteria api join table problem

Hi, i cannot use sorting on join tables. Let me explain; i have three tables. users, roles and user_roles. my JPA entities are User, UserRole, UserRolePK, Role. |User | | UserRole | | UserRolePK | | Role | |--------| |----------| -------------- -------- |id | | pk | | user | | id ...

How to stop session to save unsaved objects during query execution ?

Hi all, I have problem with session and query execution,please see code below. class A implements Lifecycle{ public boolean onUpdate(Session session){ Query test=session.createQuery("select * from Unknown"); List list=test.list(); B b=new B(); session.save(b); } } class B{ C c; public B(){ c=new C(); ...

Deleting JPA object fails due to foreign key constraints?

Why would the following query fail due to a foreign key constraint? There is no other way for me to delete the associated data that I am aware of. Query query=em.createQuery("DELETE FROM Person"); query.executeUpdate(); em.getTransaction().commit(); The I believe the offending relationship causing the problem is the activationKey fiel...