hibernate

Hibernate HQL: how to use a complex left join fetch

Hi all, I want to add a left join on TASK table when the following condition occurs: LEFT JOIN FETCH PROMPT p on (t.id = p.task.id and p.applicationName in ('XXX')) Here is my hql query: select distinct t from TASK t LEFT JOIN FETCH SERVER ser ...

hibernate post initialization

I would like to initialize class members of a persisted object as soon as Hibernate loads the object from the database. How can I do this ? More specifically: In the following persisted object, I would like to initialize date's timezone class Schedule { Calendar date TimeZone tz; } I cant do this in the constructor becaus...

Hibernate Envers throws AuditException

I am using Envers to get related entity (say entityB) for a given entity (say entityA) for a given version of enityA. I am comparing revision number of entityA with the related entity ie entityB (numbers will be same if they are in same transaction) and coming out with the revision number of entityB. Then I query enitityB like: reade...

"Integration" between Rails' ActiveRecord and Java's Hibernate

Hi everybody: let me do a bit of "concept mining" here: I am involved in mantaining/extending an application whose functionality is distributed across several servers. For example, we have a machine running the ApplicationServer, another running the DataServer and so on. This application has a Web Interface. The current UI is totally im...

can I tell Hibernate a class is immutable so it will share the objects to save cost of construction?

I have some classes that represent immutable objects (Quantity, Price, Probability). Is there some way to tell Hibernate that the objects will never change so it can re-use objects rather than creating a new object for every instance of 0 or 1 or Price= $1? I ended up creating these classes because I discovered that doubles don't do ...

hibernate subclass one to one mapping

hi all, i got a complicate mapping, i think it suppose to work...but why it compile A.d column is not existed??? public abstract Class A { private Integer Id; .. ... } public Class SubA extend A { private D d; } public Class D { private SubA subA; } A.hbm.xml <class name="A" table="A" abstract="true"/> ... <subclass ...

Cheap/free query tool for multi-database Java/hibernate developer

I'm very interesting in inexpensive (better free) SQL query tool for working with multiple databases. Generally speaking it should works with all databases which Hibernate supports, but it must work with Microsoft SQL Server (2000/2005/2008), Oracle (9i/10g/11g), Postgres 8.x, Sybase, Firebird, MySQL and HSQLDB. Must have features: ...

netbeans 6.5.1 reverse engine Oracle entity

i reverse engined entity class but the primary key is not anottaed with GeneratedValue . my table is created on oracle. do i need to add contraint on the table primary key for auto increment? rightn ow i manually edit the entity and add generatedValue . looking for better solution . i think when reverse engine, it suppose to generate...

Hibernate Criteria API equivalent for "elements()"

Is it possible to implement the following query using Criteria API? select order from ORDER as order,ITEM as item where item.itemID like 'ITM_01' and item in elements(order.items) ...

Problem with AnnotationSessionFactoryBean

I use the following configuration for initiating my SessionFactory: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/...

Hibernate in Servlet causesNoClassDefFoundError: org/slf4j/LoggerFactory

I have a Java (6) application which uses Hibernate (V3.3.2) to read data from HSQLDB, which i build and debug/run with Eclipse (V3.5.1), and it works fine. I then created a GWT (V1.7) Servlet web app, copied my hibernate classes into it, and added the same User Libraries dependencies. However when i run the servlet and try to access a U...

One-to-Many Unidirectional Parent-Child ID Cascade Save

When trying to save an ID from my parent class into a child class, I keep getting the error "ERROR - Field 'parent_id' doesn't have a default value" I have tried all types of mappings. I am using annotations. Any help on this would be appreciated Parent: @Id @Column(name="id") @GeneratedValue(strategy=GenerationTyp...

Found shared references to a collection org.hibernate.HibernateException

Hi, I got this error message : error: Found shared references to a collection: Person.relatedPersons when I tried to save addToRelatedPersons(anotherPerson) : person.addToRelatedPersons(anotherPerson); anotherPerson.addToRelatedPersons(person); anotherPerson.save(); person.save(); my domain : Person { static hasMany = [relatedPe...

Hibernate: Persisting Objects

Hi, I am trying to create new Event objects to be persisted in the database via Hibernate. The below code successfully creates one event, but when session.save(evt) is called, I get a return value of 0 (which I think is the equivalent of null). Can anyone identify what the issue is below? If you need more information in regards to class...

Value object or entity object in my Hibernate mapping?

Hey everyone, I'm trying to design a pretty simple app and am getting myself a bit confused with Hibernate's definition of entity and value objects (as defined in Chapter 4 of Java Persistence with Hibernate). What I have is an app with customers, who can place orders (one to many relationship). Each of these orders has many order line...

monitoring mysql for changes

I have a Java app using a MySQL database through hibernate. The database is really used as persistence layer: The database is read at the initial load of the program, and the records are then maintained in memory. However, we are adding extra complexity, where another process may change the database as well, and it would be nice for t...

Hibernate entity with user defined attributes

Can someone please give me some tips on modeling hibernate entities that have some known attributes while the majority are defined by the user of the system (during initial setup of the system) I need to be able to search on these user defined attributes at a later point in time. ...

I Want to get a week value

I wan to get the value of only one week. I am using the following JPA query: SELECT a FROM questions.dao.hibernate.Questions a WHERE (a.posted_date-CURRENT_DATE)>= 7 But I am getting an error message like org.hibernate.QueryException: could not resolve property: posted_date of: questions.dao.hibernate.Questions [SELECT a FROM qu...

Hibernate: page results AND know the result size

Hello, I'm doing a directory listing using Hibernate and, to avoid having tons of data every query, I'm using: Criteria paging = sess.createCriteria(Principal.class); paging.setFirstResult((int) resultSetStart); paging.setMaxResults(resultSetSize); ... List<Principal> principals = paging.list(); Now, this works fine: I guess exactly ...

SQL Server 2005 - Cannot rollback nested transaction

Hi everybody, Sometimes I get the following from SQL Server 2005 when executing a stored procedure: Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot roll back T1. No transaction or savepoint of that name was found. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source) at com...