hibernate

remove object from session in hibernate?

Hi there, my case is that, i've loaded an object X from DB using hibernateTemplate find by id, then i get some attributes from that object and added it to another object Y from the same type which was also loaded by the same X id, then i tried to saveOrUpdate object Y, hibernate thrown exception 'a different object with the same identif...

ManyToOne reference with encrypted fields gives doesn't exist error using Jasypt

I have a problem on the following situation: In my Spring, Hibernate application I got a User Entity and a UserCategory Entity. The table of the user entity got a username as identifier. This indentifierfield can't be encrypted because this table is also used by an older program without the possibility to do this. To make a ManyToOne...

How to choose DDL Primary Key constraint names with JPA/Hibernate

There exists a proprietary hibernate annotation to specify the Foreign Key constraint names that are used at DDL generation time: org.hibernate.annotations.ForeignKey. Is there also a way to specify the Primary Key constraint names? ...

No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

What is this error about? "No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here". My spring config file looks something like this. <bean id="jndiDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:/devDS</value...

What does a Hibernate join table class using composite keys and @NaturalId look like?

I found this before: http://stackoverflow.com/questions/1212058/how-to-make-a-composite-primary-key-java-persistence-annotation There's a code snippet on the first answer: @Entity public class UserRole { @Id @GeneratedValue private long id; @NaturalId private User user; @NaturalId private Role role; } So, not using ar...

Dynamic fields in JSF beans

Hi! I want to let my client create his own fields and bean in the CMS dynamically. As well, once he creates a form, I need to create an Hibernate Entity that could be saved to the database. Is there a way to do it? I am using JSF2 and Hibernate 3 With recompiling and without? ...

Error implementing Jasypt with Hibernate 3 and Struts 2

Hi, I'm trying to encrypt passwords in a webapp using Jasypt with hibernate 3. I followed the instructions on the jasypt website. Here's my hibernate mapping : <hibernate-mapping package="webapp.entity"> <typedef name="encrypted" class="org.jasypt.hibernate.type.EncryptedStringType"> <param name="encryptorRegisteredName">strongH...

Reading objects from database after a service method rollback

Hi all I have a grails service that is persisting some changes. If I rollback the transaction in the service class, throwing a RuntimeException, and later (in the same request) I try to re-read any data, I'm getting the following exception: ERROR hibernate.LazyInitializationException - failed to lazily initialize a collection of role:...

Is H3T a good solution to my lazy loading problem?

Still working on resolving this question. I came across H3T which looks like a promising solution. However, I'm really not 100% sure that it will work for me. For instance, it looks like H3T won't work when the client is local - which is how my app currently works. Has anyone out there used H3T, specifically under JBoss 5? How did it g...

How to get java.util.Map from hibernate query?

I am wondering what is the best way to get map array from hibernate query. Google says to iterate query.list(), and create/put objects into empty map array. I guess there would be some elegant and efficient way to do this. Could somebody give me idea? ...

How to define JPA?

Hi, I have just joined a on going project based on spring framework. It usage hibernate as ORM system. and it is well integrated. I have learned a lot with this project. But some how i am not satisfied with my understanding of hibernate, JPA, when they are mixed together. It has been very confusing for me to understand when my PM is tal...

Runtime one-way mapping of n tables to 1 class in Hibernate

Hi, I have data in different tables but in the same database, all of which have the same schema. Depending on some runtime variable, I want to choose which table to use when querying Hibernate. Is this possible? Note that I only use Hibernate to read table-data to objects. A solution (I think) would be one *.hbm.xml-file per table an...

Netbeans XML Editor is clobbering my custom hibernate DOCTYPE

This is happening in hibernate, but not a hibernate problem. I'm seeing this with the default XML editor for Netbeans 6.9 We do a little trick to avoid a bunch of boiler plate in our hibernate files: <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0....

Problem when persisting Entity

@Entity @Table(name = "jobitems") @IdClass(JobItemId.class) public class JobItem implements Serializable { @ManyToOne @PrimaryKeyJoinColumn(name = "forumId") private Forum forum; @ManyToOne @PrimaryKeyJoinColumn(name = "parsingJobId") private ParsingJob parsingJob; @Id @Column(name = "forumId", insertable = false, updatable = ...

Hibernate and Jboss 6.0

Hello All, I'm having problems when I'm trying to deploy on JBoss 6.0 a roo spring application. The exception I'm getting is: "Deployment "here goes my war file/" is in error due to the following reason(s): java.lang.VerifyError: (class: org/hibernate/bytecode/cglib/CglibClassTransformer, method: doTransform signature: (Ljava/lang/Class...

Hibernate tools eclipse DB problem

Hi there, am using hibernate tools with eclipse, and it was working fine, till i've changed my db, i've configured the new database and run my test cases and every thing is fine, except for hibernate tools, as now hibernate console isn't fetching tables from DB, it also didn't throw any exception, and i enetered configuration manually a...

How to delete all associations in a Hibernate JoinTable at once?

We have the following two entities with many-to-many association: @Entity public class Role { ... @ManyToMany @JoinTable( name = "user_has_role", joinColumns = { @JoinColumn( name = "role_fk" ) }, inverseJoinColumns = { @JoinColumn( name = "user_fk" ) } ) private Set<User> userCollection; ... } and @Entity publi...

How to create relationship to the same entity with JPA (Hibernate)?

I have an entity User and it should have property manager where manager is another user (one manager can manage many users, any user may have only 1 manager or have not any). How can I implement this? I tried something standard @ManyToOne @JoinColumn (name = ??? /* what should be here? */, nullable = true) private User manager; but ...

Filter list contained in entity returned by jpa/hibernate query

Hi all, I have a simple jpa entity 'ApplicationForm' with a one to many list in it: @OneToMany(cascade=CascadeType.REMOVE, mappedBy="textQuestion") private List<Dictionary> questions; The variable Dictionary contained in ApplicationForm is just another plain entity with just the text of the question. The corresponding database tab...

Hibernate : OneToMany mapping not based on PK ?

I have 2 entities/tables. One is a proper entity, let's call it data. It has a number of fields containing so-called "multilingual codes". The second table, code, contains the multilingual values themselves. Here is some example data : Data table id name continentCode countryCode ------------------------------------ 1 ...