hibernate

Does Hibernate 3.5.0-CR-2 release support JPA2.0

I see that Hibernate home page has a symbol informing that it implements JSR 317, but I couldn't find if it implements the full spec. Does anybody knows if Hibernate 3.5.0-CR-2 fully implements the JSR 317? I can see from their JIRA that everything is closed related to JPA 2.0: http://opensource.atlassian.com/projects/hibernate/browse/...

How to run Spring 3.0 PetClinic in tomcat with Hibernate backed JPA

OK, this probably is supposed to be the easiest thing in the world, but I've been trying for the entire day, and it's still not working.. Any help is highly appreciated! EDIT: For the correct procedure, please see Pascal's answer. My wrong (since I did not disabled LoadTimeWeaving) procedure is left for reference..: What I did: D...

hibernate show real sql

Hi all, if I set <property name="show_sql">true</property> in my hibernate.cfg.xml configuration file in the console I can see the sql. But it's not REAL sql... Can I see the SQL code that will be passed directly to database? Example: I see select this_.code from true.employee this_ where this_.code=? Can I see select employe...

Hibernate @Index on @Enumerated field doesn't work

I am using Hibernate to talk to my DB. I have one field that is an enumeration and it is going to be used in a slow query. So I'd like to index it. I've put the following annotations on the field: @Column(name="RIGHT_TYPE", unique=false, nullable=false, length=10) @Enumerated(EnumType.STRING) @Index(name = "ABC_INDEX") protected RightTy...

Hibernate annotations cascading doesn't work

Hi all, I've decided to change hbm.xml style to annotations using hibernate. I had in my hbm.xml: <hibernate-mapping package="by.sokol.jpr.data"> <class name="Licence"> <id name="licenceId"> <generator class="native" /> </id> <many-to-one name="user" lazy="false" cascade="save-update" column="usr"/> </class> </hibernate-mappin...

Detach an entity from a JPA persistence context (JPA 2.0 / Hibernate / EJB 3 / J2EE 6)

Hi, I wrote a stateless EJB method allowing to get an entity in "read-only" mode. The way to do this is to get the entity with the EntityManager then detach it (using the JPA 2.0 EntityManager). My code is the following: @PersistenceContext private EntityManager entityManager; public T getEntity(int entityId, Class<T> specificClass,...

How to generate comments in hbm2java created POJO?

My current setup using hibernate uses the hibernate.reveng.xml file to generate the various hbm.xml files. Which are then turned into POJOs using hbm2java. We spent some time while designing our schema, to place some pretty decent descriptions on the Tables and there columns. I am able to pull these descriptions into the hbm.xml files wh...

simplest criteria query

What is the simplest hibernate criteria query equivalent of SELECT name FROM people WHERE id='3' is it : criteria.add(Expression.eq("id", 3)); and how can I retrieve it to String variable the value of name field, the IDs are unique ...

Does beginTransaction in Hibernate allocate a new DB connection?

Hi folks - Just wondering if beginning a new transaction in Hibernate actually allocates a connection to the DB? I'm concerned b/c our server begins a new transaction for each request received, even if that request doesn't interact with the DB. We're seeing DB connections as a major bottleneck, so I'm wondering if I should take the t...

How I can use searching by Hibernate with Java

Hi All ; I want to make searching on my database with hibernate in Java, how can I do that? Normally when I am using JDBC I wrote this code : String Sql="select * from table1 where id like '"+jTextField1.getText()+"%'"; but I want to do that with hibernate database operation, do I need to use session.load(..) ? Thanks from now... ...

HSQLDB Constraint Violation & SQL Query Log for an HSQLDB in-memory setup

We have a setup where we are using an embedded HSQLDB for backing Hibernate/JPA unit tests in java, and we are using the in-memory database mode since we simply want the database thrown away after the test run. My problem is that one of the tests is failing due to a constraint violation and HSQLDB lists the column as SYS_CT_286, and the ...

Using Hibernate outside the context of Tomcat

Anyone used Hibernate to access a DB in a pure java app (not a web application)? What was your experience like, did it take long to set up and get going? ...

Grails GORM (Hibernate) query

Hello, I'm trying to do the below sql statement in GORM select * from table1 where table1.x not in (select x from table 2 where y='something'); so, I have two tables, and needs to find the entries from table 1 which are not in table 2. In Grails def xx= table2.findByY('something') def c = table1.createCriteria() def ...

can't execute trigger through hibernate

org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) I have DATABASE trigger. But when I save object through hibernate session object, Its throws above exception ...

Hibernate criteria -- alias

Hello, I'm struggling a bit with the concept of alias in Hibernate. My situation is the following: Order @OneToMany(cascade=CascadeType.ALL,mappedBy="m_order") private Set<OrderDetail> m_details; OrderDetail @ManyToOne(cascade=CascadeType.ALL) @JoinColumn(name="product_id") private Product m_product; @ManyToOne(casca...

Date query with Hibernate on Timestamp Column in PostgreSQL

A table has timestamp column. A sample value in that could be 2010-03-30 13:42:42. With Hibernate, I am doing a range query Restrictions.between("column-name", fromDate, toDate). The Hibernate mapping for this column is as follows. <property name="orderTimestamp" column="order_timestamp" type="java.util.Date" /> Let's say, I want to...

Using serializable in hibernate what underlying database types do i use.

I need to use a serializable type in hibernate (to store a Subject (security)) All this works fine. I just need to know what the underlying database types are for the following databases: MSSQL - I used 'image' db2 - postgre - mysql - Thanks.. ...

Problem updating BLOB with Hibernate?

hi, i am having problem updating a blob with hibernate. (i am using Hibernate 3.3.1-GA) my model have these getters/setters for hibernate, i.e. internally i deal with byte[] so any getter/setter convert the byte[] to blog. I can create an initial object without problem, but if I try to change the content of the blob, the database colum...

HowTo JAX-WS+AXIS(standalone)+Hibernate

Hi, I am searching for a right way to use Hibernate in my web-service. To begin I whant to describe, how it is working now. I have made a simple class with @WebMethod and @WebService annotations and stored it in axis2-"1.5.1/repository/servicejars" folder. This class invokes real service implementation using reflection. And all implemen...

Hibernate advanced select

We want to get a row from a table using Hibernate a la: select max(id) from mytable where date = <date> Then select * from mytable where id = <max_id> We are currently using Hibernate to map mytable to Java domain objects. I know how to load the domain object based on an id. So I could just do #1 using JDBC and then load the dom...