hibernate

AbstractEntityPersister returning false for Column marked as nullable.

Hi, I am trying to insert a record into a table using Hibernate. Before inserting the record I check for all fields which are not provided with any value i.e null, if these columns allow null values. I have made use of AbstractEntityPersister class to get column meta information. Below is the method which checks if the given column all...

How to go about creating a first startup wizard with Wicket? (Database table creation etc.)

Hello. I'm working on a Java Web Application with Wicket, Spring and Hibernate. The web application is not particularily large (I have one DAO and one service), but I'd like to offer the users that deploy the application a startup wizard much like the ones found in Wordpress. When the webpage is accessed for the first time (no database...

How to generate id based on two foreign keys in JPA / Hibernate?

I have a simple question regarding Entity declaration in JPA. I have an entity with 2 foreign keys, which are not null and form an uniqueConstraint. First I was thinking about a composite key, composed of the two foreign keys, but I heard that this is a legacy design, and not the recommended way of designing new tables. So I am interest...

Is it possible to dynamically trigger calling of the @PostLoad method only on demand

Env: JBoss Seam, JPA, Hibernate We use the @PostLoad annotation to dynamically initialize some of the transient variables in our @Entity (sometimes this involves looking up the parent entity to initialize status - which is a costly operation). But under certain circumstances, we don't want this @PostLoad to get triggered, since we will...

hibernate - spring/bean mapping set

I'm pretty much a newb with spring-hibernate and I have been trying to make it work. I have a data model like this: patient prescription ---------- -------------- patient_id* prescription_id* first_name patient_id* last_name date ... I'm using spring beans with hibernate ...

Hibernate HQL update with a subselect in set clause

Hi all, I'm trying to do an update in hibernate HQL with a subselect in a set clause like: update UserObject set code = (select n.code from SomeUserObject n where n.id = 1000) It isnt working, it is not supported? Thanks Udo ...

Can I use the current release of Unitils (3.1) with JPA 2.0?

Using Hibernate EntityManager 3.5.3-Final together with Unitils 3.1 results in: unitilsAfterTestTearDown(com.unifiedpost.payments.model.TestAccount) Time elapsed: 0.02 sec <<< FAILURE! java.lang.AbstractMethodError: org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMo...

bean validation- hibernate error

I am getting following exception when trying to run my command line application: java.lang.ExceptionInInitializerError at org.hibernate.validator.engine.ConfigurationImpl.<clinit>(ConfigurationImpl.java:52) at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:43) at jav...

how to make a clause in hibernate mapping files?

I want to add a (where) condition in hibernate mapping file when fetching, how could i do that for example fetch="select" where id != 1 ,am not using annotations also, so please specify within the mapping (hbm) files. ...

Will CompassGps roll back if the transaction is rolled back?

If CompassGps mirroring is used with Hibernate, what happens if the database transaction rolls back? Will the changes to the index be rolled back (assuming file store for the index)? It seems like if the Lucene index is stored on the disk it won't be automatically rolled back, unless Compass is smart enough to handle that for you. FWI...

Hibernate - encrypted reference by relations on usernames

I was wondering if my idea is possible with hibernate. What I want is that there is one table with usernames and every table wich has a reference to this table has the username encrypted in a column. So the username doesn't stand in normal text but encrypted in every table which have a reference to the user table. So I need something...

Serializable Hibernate data object for GWT RPC

I have a simple POJO mapped to a table using Hibernate. Which works just fine. public class Patient implements Serializable { private int patientId; private String firstName; private String lastName; private Set<Prescription> patientPrescriptions; public Patient() {} ... } My problem is I want to be able ...

Retrieving only the superclass in hibernate

I have a superclass and a subclass mapped to have a table for each class like this @Entity @Table(name="superclass_table") @Inheritance(strategy=InheritanceType.JOINED ) public class SuperClass { } @Entity @Table(name="subclass_table") public class SubClass extends SuperClass { } When I make session.createCriteria(SuperClass.cl...

hibernate double logging

hello all, I am working on a project using Spring, hibernate and struts2. Queries and system outs are being logged twice. I do have slf4j-api-1.6.1 and slf4j-log4j12-1.6.1 jars in lib folder. log4j.properties log4j.logger.org.hibernate=info applicationContext.html <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.spri...

Is it possible to put all output from show_sql in a seperate file?

When developing or running a spring mvc app locally that uses hibernate, it would be nice if I could get the output of all sql to a seperate file. Is this possible? I know there is a hibernate property show_sql but I believe that will just get jumbled together with all other log4j logging info correct? ...

Implementing lazy loading of a many-to-many on EJB3 beans

I have two database tables, User and Role. I'm trying to set up a bidirectional many-to-many mapping in my application but I'm running into performance issues when eagerly fetching. The many-to-many works using a UserRole join table. My DTOs look like this (fat has been trimmed): UserDTO.java @Entity @Table(name = "[redacted].User") pu...

Where to put hibernate annotations?

Where do i put my hibernate annotations? Is it the line above my instance variable? Or before the getter? Or before the setter? Or doesn't it really matter? Thanks a lot ...

Hibernate will not make indexes when creating tables from annotations

Hi, I'm using hibernate with hbm2ddl.auto=update so that it'll automatically generate my oracle tables for me (i've no intention of learning oracle's sql). So far, so good, until now i'm trying to get it to create an index. As far as i can tell, i've made my annotations correctly: package data; import javax.persistence.*; import org.hi...

How to map this relationship in Hibernate ?

I have 2 tables : The table Data : id, plus many fields. Some of these fields are 'codes' which reference multilanguage values from the next table, for example country_code, continent_code. The table Thesaurus which contains the multilanguage codes, with columns: code, code_type, language, text. Code is unique for one code_type but the...

Schema generation for maps in Hibernate

Hi there, I have a class Folder and a class File with a one-to-many relationship between them, implemented with a Map. Here is the hibernate mapping file: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3...