hibernate

Atomikos rollback doesn't clear JPA persistence context?

I have a Spring/JPA/Hibernate application and am trying to get it to pass my Junit integration tests against H2 and MySQL. Currently I am using Atomikos for transactions and C3P0 for connection pooling. Despite my best efforts my DAO integration one of the tests is failing with org.hibernate.NonUniqueObjectException. In the failing ...

@OneToOne and @JoinColumn, auto delete null entity , doable?

I have two Entities , with the following JPA annotations : @Entity @Table(name = "Owner") public class Owner implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private long id; @OneToOne(fetch=FetchType.EAGER , cascade=CascadeType.ALL) @JoinColumn(name="Data_id") private Dat...

JPA 2.0 Implementations comparison : Hibernate 3.5 vs EclipseLink 2 vs OpenJPA 2

What's your choice? Do You have any suggestions and experience? I'm developing an application with Hibernate 3.5 and Spring 3.0 Pros: Good documentation Easy configuration and helpful logs Popularity - wide community Some extensions to JPA Some additional Tools - JBoss Tools for Eclipse, hbm2ddl, generating static metamodel etc... ...

EAR deployment failed because of Hibernate SessionFactory

I made a maven project that includes EJB, WEB and EAR modules. But I don't use hibernate in my project. So I don't add hibernate dependencies. I successfuly tested my project in JBoss 5 but when I tried to test in JBoss 4.2.3 it failed. It complains about: Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.hiber...

Java EE application database architecture

Hello ... I'm developing java EE database application(JSF) where I fill drop down menus from database. I looked for some tutorials and I find that they used the session bean to initialize these drop down values from database (using hibernate).As my application contains a lot of these is this a good strategy to fill values from database?...

SqlQuery and result caching in Hibernate

Hi! I need to count records amount like this: Query qry = session.createSQLQuery("SELECT count(id) FROM object_permission_role WHERE object_permission_id=?"); as well, I am using query cache true. How can I cache my sqlquery that returns the count(id) until someone in the code updates/delete/add any row to object_permission_role tab...

Problem test with seam and hibernate (JPA)

Hi guy, I work on an application which use Seam and Hibernate (with Jboss 5.1 server). I have 4 projects in my eclipse (Portail, Portail-ear, Portail-ejb and Portail-test). When I start the application, all work fine (I can go in localhost:8080). But when I want to realise some tests in the test project, I have a problem. Here is the ...

JPA DAO integration test not throwing exception when duplicate object saved?

I am in the process of unit testing a DAO built with Spring/JPA and Hibernate as the provider. Prior to running the test, DBUnit inserted a User record with username "poweruser" -- username is the primary key in the users table. Here is the integration test method: @Test @ExpectedException(EntityExistsException.class) public void save...

How to delete child table records during the update of parent table using Hibernate

I have a Parent Table A and child tables B,C with many to one relations. Lets say I have data like, for primary key 1 in parent table A I have 3 rows in child table B and 4 rows in child table C. Now if I want to delete the rows of the child table during an update of the parent table(that means Now, I want to update the table only with...

Are JPA / Hibernate Exceptions not translated?

I finished a battery of DAO integration tests using JPA/Hibernate and many of them expect exceptions to be thrown. However, I have noticed that Hibernate seems to ignore the nice heirarchy of exceptions provided by the JPA spec and instead always throws the generic PersistenceException that wraps their Hibernate specific exception. Am ...

Eclipse JPA structure view, detail view, and persistence.xml editor not working?

Eclipse has pretty cool JPA Structure and JPA Detail views along with a persistence.xml editor and a JPA perspective. However, I cannot seem to get them to "turn on". I had them all working several months ago, but something must have changed. Any tips as to what secret sauce is needed to get them working again? ...

Does Hibernate log the values that it assigns to placeholders in prepared SQL statements?

Does Hibernate log the values that it assigns to placeholders in prepared SQL statements? How can configure Log4j so that it writes these values to my log files? ...

Saving owned/child objects in Hibernate

I'm having a hard time wrapping my head around the way hibernate objects work. Here's a little chunk of what my model looks like: JobOpening: @ManyToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL) @JoinTable( name="jobOpening_questionSet", joinColumns=@JoinColumn(name="jobOpenings_id"), inverseJoinColumns=@J...

Hibernate/Spring: failed to lazily initialize - no session or session was closed

For an answer scroll down to the end of this... The basic problem is the same as asked multiple time. I have a simple program with two POJOs Event and User - where a user can have multiple events. @Entity @Table public class Event { private Long id; private String name; private User user; @Column @Id @GeneratedValue public Lo...

In Grails / Hibernate Can you set the generator to increment only if not assigned?

is there a way to have hibernate use auto generated ids if it wasn't assigned but use the assigned value if it was? ...

org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002

Hi at all, I'm having a issue trying to get working a JPA nativeQuery. I'm having a org.hibernate.MappingException: No Dialect mapping for JDBC type: 2002 when a try to do a nativeQuery and get a geometry field type. I use oracle and org.hibernatespatial.oracle.OracleSpatial10gDialect. The geom fields is mapped as: @Column(name="geo...

Getting changes in one column of an historical table

Hello, I have a table which stores historical data. It's mapped to an Entity with the following fields (I use JPA with Hibernate implementation): @Entity @Table(name="items_historical") public class ItemHistory{ private Integer id; private Date date; @Enumerated(EnumType.ORDINAL) private StatusEnum status @ManyTo...

Strange JPA one-to-many behavior when trying to set the "many" on the "one" entity

I've mapped two entities using JPA (specifically Hibernate). Those entities have a one-to-many relationship (I've simplified for presentation): @Entity public class A { @ManyToOne public B getB() { return b; } } @Entity public Class B { @OneToMany(mappedBy="b") public Set<A> getAs() { return as; } } Now, I'm trying ...

Hibernate Initial SessionFactory creation failed

I'm trying to use hibernate to fill my jsf selectonemenu in ApplicationBean (in Liferay). The problem is that I got Initial SessionFactory creation failed problem. Before putting my functions in the applicationbean I was setting them in sessionbean and I got no error. For now the full error Initial SessionFactory creation failed. ja...

Hibernate Search synchronous execution in main thread

It seems that Hibernate Search synchronous execution uses other threads than the calling thread for parallel execution. How do I execute the Hibernate Search executions serially in the calling thread? The problem seems to be in the org.hibernate.search.backend.impl.lucene.QueueProcessors class : private void runAllWaiting() throws ...