hibernate

Are Hibernate filters only applied after the data has been loaded from db?

I've found some contradicting information on the net. Does anyone know whether Hibernate filters affect the generated sql, or is it just filtering the data as it's read from the database? Thanks! ...

Different behavior/content of Spring/Hibernate/SessionFactory when running Maven+Surefire vs Eclipse+jUnit

I try to be quick. In fact, one of my jUnit test is failing when running the Maven command of my project (mvn install, so with the Surefire plugin) while it's successful when I run it in Eclipse. I tried many things and the only difference I managed to see is that : - With Maven/Surefire in debug-mode, in the Hibernate-SessionFactory I...

Project Structure for Hibernate Struts project?

I started developing one Blog Website based on Hibernate and Struts. I was wondering how to maintain the structure of the directory and files. That is, the presentation, hibernate DB access layers, controllers and business layers. Any suggestion? Regards Swar ...

Hibernate - map object that belongs to two other objects (object with 2 parents).

I'm having a bit of trouble mapping the following: public class Operation { private Integer id; private String name; private List<Item> items = new ArrayList<Item>(); //set/getters/hashcode/etc. omitted public void addItem(Item i,Operation end) { i.setOperationStart(this); i.setOperationEnd(end}; items.add(i); ...

Hibernate and NonUniqueObjectException

Hi all, i have an entity that contains two other entities with @ManyToOne relationship. @Entity public class A extends Serializable{ @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @ManyToOne @Cascade(CascadeType.SAVE_UPDATE) private B b; @ManyToOne @Cascade(CascadeType.SAVE_UPDA...

please suggest about a basic example

any expert tell me where i find a basic example of Srtuts2+Spring+Hibernate ...

Using hibernate with existing database.

I want to use hibernate against an existing database. I need to mostly read data from the db and very occasionally modify a field. I want to be able to update a single field in the row, but i need to make sure that all the other fields are not touched. Does hibernate guarantee that a field will be written back the same as it was writt...

Does grails / hibernate store Dates with miliseconds in PostgreSQL?

I'm currently using grails with classes storing java.util.Date fields als DATETIME. However I need the precision / miliseconds to be stored as well which I think is not possible with MySQL. If I switch to PostgreSQL, will it store my Dates with milisecond precision (or is it easy to configure it this way)? ...

Hibernate-annotations 3.4.0.GA and slf4j?

I have a maven project A that use hibernate-annotations 3.4.0.GA which use the slf4j-api version 1.5.5 (checked through the dependency tree in the pom.xml file). Further project A specifies slf4j-log4j12 version 1.4.2 as a dependency. I have another maven project B which depend on project A. In project B I have specified the following d...

What does 'length' attribute in hibernate mapping file do

Hi, I read that 'length' attribute in hibernate mapping file for a table column is optional. Does it truncate data while inserting into database if length exceeds the column length? Thanks Nayn ...

Hibernate Cache and JdbcTemplate

Will the Hibernate caching(1st, 2nd, or Query) work when I use JdbcTemplate? I got to know that the caching is one of the advantage in using ORM instead of traditional JDBC. So, If I got to use Hibernate's JdbcTemplate, still can I enjoy the benefits of hibernate caching? ...

org.hibernate.hql.ast.QuerySyntaxException

i get this exception when i was running an application please give me a solution in my mapping file like as follows: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; <hibernate-mapping> <class name="mobilserv....

HibernateToolTask (hbm2hbmxml) doesn't generate index in hibernate-mapping from @org.hibernate.annotations.Index annotations

I am trying to generate hibernate-mapping from POJOs with hibernate annotations. Then I want to use liquibase to generate database schema. So I need indexes to be defined in my POJOs. Sample POJO: @Entity public class A { @Id @GeneratedValue private Long id; @Index(name = "IDX_NAME") @ForeignKey(name="sd") p...

Hibernate listener performance and loadeventlistener

I need to restrict the resulting rows from each table/object depending on my security rules per logged user. I thought to use implement PreLoadEventListener. Regarding performance - how expensive is it to use onPreLoad for each entity? does Hibernate assign the relevant listener via Reflection? Is it done once per Hibernate session o...

Can an NHiberate entity have a natural-id in a component?

It seems impossible to me to have a natural-id in a component. public class User { private IAccount account; public User(string name, string password){ account = new Account() { UserName = name, Password = password }; } } public class Account : IAccount { public st...

HSQLDB and Hibernate/JPA - not persisting to disk?

Something of an novice with HSQL and Hibernate... em.getTransaction().begin(); for (Activity theActivity : activities) { em.persist(theActivity); } em.getTransaction().commit(); em.close(); followed by... EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); System.out.println("QUERY:: " + em.createQuery("S...

hibernate cascading delete, why not one delete on the foreign key ?

I'm wondering why hibernate generates 1 delete per entity on a child table instead of using one delete on the foreign key Here's the hibernate.cfg.xml (No i's not the next SO :-t <hibernate-configuration> <session-factory> <property name="hibernate.connection.url">jdbc:hsqldb:file:testdb;shutdown=true</property> <pr...

Doing a join over 2 tables in different databases using Hibernate

Hi everybody, I have two tables in two separate oracle databases (not schemas) that I need to join in Hibernate. Currently, I have two hibernate sessions going out to the separate databases. Before anybody says look at Hibernate Shards, I have spent a better part of a day looking at that sub-project and have found that: it is for hor...

Hibernate: different object with the same identifier value was already associated with the session

when I use the DAO.update(userbean), session.SaveOrUpdate(e);throw the Exception:different object with the same identifier value was already associated with the session the function is like next: public E save(E e) { Session session = null; try { session = sessionFactory.openSession(); log.debug("session="+s...

cannot resolve property when criteria refers to a embedded property.

I seem to be unable to create a query with a criterion which refers to a property inside a Embedded class. When i use "entity.embedded.property" it fails. If i create an alias of "entity.embedded.property" to itself the query works...Any tipes will be appreciated... ...