hibernate

JPA / Hibernate - ConstraintViolationException by removing an element

Hello! I have a JPA/Hibernate problem with a n:m relation (Project <-> Person) with a join table. The Project is the mapping owner and has a (cascade = CascadeType.ALL). Now I want to remove a project which is associated with a Person, so there is an entry in the Project_Person join table, but I get a org.hibernate.exception.Constrai...

Hibernate - AnnotationConfiguration deprecated

Hello! I am using Hibernate in version 3.6.0 and the AnnotationConfiguration is marked as deprecated. Here is the the line in my HibernateUtil.java class: sessionFactory = new AnnotationConfiguration().configure("/hib.cfg.xml").buildSessionFactory(); What's the replacement for AnnotationConfiguration? Best Regards Tim. ...

NPE in HQL subquery

I have an error in the following HQL Query: em.createQuery( "SELECT new com.magenta.sovereign.entity.view.ThirdPartyReportView(" + "e.id, " + "e.vehicleRegistrationNumber, " + "e.driverName, " + "e.thirdPartyAssignee.firstName, " + ...

How can I configure Hibernate to immediately apply all saves, updates, and deletes?

How can I configure Hibernate to apply all saves, updates, and deletes to the database server immediately after the session executes each operation? By default, Hibernate enqueues all save, update, and delete operations and submits them to the database server only after a flush() operation, committing the transaction, or the closing of ...

C3p0 connection pooling for jpa in persistence.xml not working?

I'm still getting JDBC timeouts after trying to configure c3p0 following all of the examples I could find. I'm using JPA, Hibernate, Tomcat, MySQL [AWS RDS]. Here's the snippet from persistence.xml: <property name="javax.persistence.jdbc.url" value="jdbc:mysql://url..." /> <property name="javax.persistence.jdbc.driver" value="com.mysql....

Best practice: best database naming convention for JPA?

In Java the naming convention for properties en classes (entities) are done the CamelCase way: @Entity public class UserMessage implements Serializable { @Id private Integer id; private String shortTitle; private String longTitle; private String htmlMessage; } But in the SQL world it’s considered a best pract...

java.lang.IllegalStateException: Timer already cancelled when webapp redeploys on tomcat

Hi, Using Hibernate in a struts2 webapp when the application redeploys I get this error when trying to access pages after redeploy. java.lang.IllegalStateException: Timer already cancelled. Just after redeploy tomcat logs the following output which indicates the cause of the problem is that Hibernate is not shutting down properly whe...

Sorting on Column in Type Table with ColdFusion ORM

Hi all, I have three tables, with the following structure: http://dl.dropbox.com/u/2586403/ORMIssues/TableLayout.png The three objects I'm dealing with are here: http://dl.dropbox.com/u/2586403/ORMIssues/Objects.zip I need to be able to get a PartObject, and then pull all of its Attributes, sorted by the AttributeName in the Type...

Extended Session for transactions

What is 'Extended Session Antipattern' ? ...

Is multiple named query file possible

I always see a single file being used for named query. I have never seen multiple file for queries, but can it be done? ...

Hibernate Interceptors or Events for Audit Trail?

I record a history of all changes to some entities and am about to implement a mechanism similar to Envers to take care of this automatically. My question is whether to use Hibernate interceptors or their event system? It seems like interceptors is a little simpler and does all I need. And Hibernate's own documentation suggests using ...

Can nhibernate be used without doing the XML mapping?

I have a lot of classes and this is a lot of work to do the XML mappings. ...

Grails (Hibernate) Criteria query

Hi, I have a domain class in my Grails app that looks like this: class Event { Date date } I want to write a criteria query that selects events that occurred in a certain month of a certain year, any suggestions? Thanks, Don ...

Hibernate Transaction information

Given that you have a lot of domain objects, that all interact with one another, it would be very useful to know which objects have changed in a particular transaction. Is this possible ? I would like to essentially do this : public void someBusinessLogicMethod(someparams) { Session s = getSession(); Transaction tr = s.beginTransac...

urlrewrite and opensessioninviewfilter doesn't work together

I started my new Spring mvc project and I decided to go with SpringSource ToolSuite. When I create a project it automatically creates urlrewrite filter in my web.xml, which I'm enjoying very much. However, this brilliant urlrewrite thing doesn't seem to work with opensessioninviewfilter. Does anybody can help me? Here is my web.xml(I tr...

doubts installing hibernate ,hsqldb plugins for eclipse helios

hi, I am taking my first steps developing web apps using eclipse,jee,hibernate,spring and hsqldb. I installed helios version of eclipse and installed wtp through the updater.But trying to install the plugins for others ,I am having doubts.. hibernate: I tried the download jboss.org/jbosstools/updates/stable/ as the hostname in updater a...

Wrong query generated with @OrderBy annotation

Hi, I am using Hibernate3 and i have an entity with the following collection: @ManyToMany @JoinTable(name = "buys_publishers", joinColumns=@JoinColumn(name="buy_id", referencedColumnName = "buy_id"), inverseJoinColumns=@JoinColumn(name = "publisher_id", referencedColumnName = "publisher_id")) @OrderBy("name") private List<Publi...

using hibernate criteria to select into value objects

I'm trying to find out if it is possible to do the following HQL using the Hibernate Criteria API: String hql = "select new InitialCount(substring(name, 1,1), count(id)) from Person group by substring(name, 1,1)"; Where InitialCount is a very simple bean with a string and long contructor: public static class InitialCount { privat...

Problem with generated SQL from Hibernate (MS SQLServer)

Hi, I have a problem with Hibernate generating an SQL that do not work on SQLServer (works on PostgreSQL without any problems). I have tried to set the hibernate dialect for SQLServer but the same SQL is still generated and still do not work. The HQL query looks like this: select count(t) from ValidationLog t The generated SQL looks ...

How do you specify OrderBy clause on two columns

We would like to orderBy 2 columns in the Seam EntityQuery interface as well as the JPA model. How do we do this? @Entity public class A{ @OrderBy(???) // should this be hardcoded here, is it database agnostic List<B> bobjects; } @Entity public class B { public short startTimeHrs; public short startTimeMins; } @Name("bList") p...