hibernate

Hibernate "could not execute query" Exception!!

exception javax.servlet.ServletException: org.hibernate.exception.GenericJDBCException: could not execute query org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) org.apache.struts.action.ActionServlet.doGet(A...

JPA and Spring transactions - please explain

Hi, today I have coded a test case for my application, to see how transactions behave. And I have found that nothing works the way I thought it does. I have a Spring-based application using Hibernate as JPA provider, backed by MySQL. I have DAO objects, extending Spring's JpaDaoSupport. These are covered by Spring's transaction managem...

Get annoted hibernate tablename from POJO

Hi guys, I have an entity which is declared roughly like: @Entity @Table(name = "myUserTable") public class User implements Serializable { ... } I'm making a generic DAO class, and in doing so I'd like to retrieve the "myUserTable" name. Is there any way I can reach this name? Cheers Nik ...

How to get hibernate-entitymanager to work with JTA out of JBoss?

I am building a tool for out-of-container EJB testing. I have managed to run Hibernate's EntityManager in it successfully. Now I want to integrate it with JTA to enable strict control of transactions. The problem I am faced with is the following: Hibernate seems to require JNDI to work correctly with JBossTS (JBoss's JTA implementation)...

Inserting a generated value into a Hibernate record

I am creating a record of Widgets with Hibernate. It's pretty basic. I've got an hbm.xml file describing the object, a DAO class that creates and saves them, etc. However, there is an explicit sorting order to the widgets, and each new Widget needs to be inserted with a sortIndex column value that is greater than all other sortIndex c...

Can I make an embedded Hibernate entity non-nullable?

What I want: @Embedded(nullable = false) private Direito direito; However, as you know there's no such attribute to @Embeddable. Is there a correct way to do this? I don't want workarounds. ...

Database-sessions in Spring

Hi guys, I'm quite new to Spring, and I would like to understand a bit more about sessions. I've mapped a legacy database with Hibernate annotated entities and built a couple of service objects to fetch, retrieve etc. My entities also contain other entities (mapped through foreign keys) and sets of entities. When I traverse the entitiy ...

How to insert an "Optimizer hint" to Hibernate criteria api query

i have a hibernate query that is dynamically put together using the criteria api. it generates queries that are unbearably slow, if executed as-is. but i have noted they are about 1000% faster if I prepend /*+ FIRST_ROWS(10) */ to the query. how can i do this with the criteria api? i tried criteria.setComment(..), but this seems to be ...

Creating a sequence based on some criterions

Hi I have the following class @Entity public class Foobar { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @ManyToOne private Organization organization; private Long orderNr; } What I'm trying to do is to create an incrementing order number for this object. The problem is that the order...

Hibernate - renaming objects with a unique constraint.

Say you have a bunch of Article objects, with a "title" property. Then there's an ARTICLE table with a TITLE column. The TITLE column has a unique constraint. The UI shows all the articles on one page, with a text field for editing the title. Imagine a situation where you have two articles X & Y, X having the title "1" and Y having the...

Problem with Entity update with jpa/hibernate

I have this entity class, called "Pagina" and I want to update the entry in the database based on the changes made to the entity. This isn't working. I get no errors, but the db is not changed. @Entity @Table(name = "PAGINA") @NamedQueries({@NamedQuery(name = "Pagina.findAll", query = "SELECT p FROM Pagina p"), @NamedQuery(name = "Pag...

Hibernate: batch_size? Second Level Cache ?

I have a Hibernate domain object that gets loaded by different parts of the application. Sometimes it's advantageous to lazy load every association and others it's better to load the entire thing in one join. As a hopefully happy compromise I've found: Using batch fetching, Hibernate can load several uninitialized proxies if one proxy...

What is the "persistence domain model"

I see a lot of references to this in Java software discussions specifically those talking about Hibernate. I cannot find any definition of what it is and why I care about it. Any one got a good definition for it? ...

Custom OneToOne Hibernate/JPA Association

I have a database that can have different types of relatinships based upon what data was updated during the last business transaction. An example would be in a policy writing application. The main table contains generic policy level information and there are related tables containing information such as the agent's information and the ...

How do I rewrite this hibernate-mapping with annotations?

I'd like to configure this mapping with annotations instead of XML. Here's the mapping config (sanitized for public consumption): <hibernate-mapping package="com.test.model"> <class name="Parent" table="parent"> <composite-id name="id" class="ParentCompositeKey"> <key-property name="first_id" type="long" column="first_i...

Why was the name "Hibernate" chosen for Java's Hibernate library?

Does the term "hibernate" mean something specific with regard to ORM libraries? Is there a story behind it? ...

Lazy query.list() in Hibernate?

I am using Hibernate 3.3.2 GA + Annotations. Is there a way get a lazy list back when calling list() on a query? The documentation (19.1.3) remarks: list() does not usually return proxies. The question is: how do I make it return proxies (or more perhaps more precisely one proxy which returns entity instances during the actual ite...

PostgreSQL identity in JPA single table hierarchy

I'm seeing strange behaviour when using PostgreSQL in a Hibernate/JPA environment with a single table inheritance hierarchy. Firstly my environment: PostgreSQL 8.3 Spring 2.5.6SEC01 Hibernate-entitymanager 3.4.0.GA (installed from Glassfish update tool) Hibernate-distribution 3.3.1.GA (installed from Glassfish update tool) Glassfish V...

groovysh and groovy classes visibility and annotation parsing

Hello Everyone, I started using groovy intensely to prototype everything. This is amazing. But I faced the problem with groovy shell. Next code I run with groovy filename.groovy and everything works as expected. But within groovysh command load filename.groovy Doesn't work: it can't find class Book. The code: import org.hibern...

What could cause "PROCEDURE schema.identity does not exist" using MySQL and Hibernate?

Using Java, Hibernate, and MySQL I persist instances of a class like this using the Hibernate support from Spring. @Entity public class MyEntity implements Serializable { private Long id; @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId() { return id; } public void setId(Long id) { this.id = i...