hibernate

Delete a hibernate entity with tapestry5 gives : "a different object with the same identifier value was already associated with the session"

I have an error being thrown on deleting an entity. I have users in only one group at a time, so it's a ManyToOne relationship on the User class. In the page class I have a property group: @Property @Persist private Group group; that is populated on page activation: public void onActivate(Group g) { group = g; } When the dele...

JPA EntityManager, how does it work??

Sorry for the noob question, but I'm having problems with JPA+Hibernate so I thought that something is not clear in my mind. I have some entities, say A, B, C, D and I have coded AMethods, BMethods, CMethods, DMethods. Each of the *Methods classes contain EntityManager initialization via EntityManagerFactory and some methods that basica...

Hibernate with Tomcat vs Hibernate with JBoss

I am a newbie trying to figure out the pros and cons of using Hibernate with Tomcat and with JBoss. I am developing a web application with Flex at the front-end, BlazeDS as the messaging service and Java at the back-end. We have decided on using Hibernate as the persistence mechanism but would like to know the trade-offs of using it wit...

Hibernate - Get all entites created in a cascading create

Hi all If I have an entity with a parent / child relationship (and Cascade=CascadeType.ALL), and call: getSession().save(parent) the primary key of the parent is returned. Is there a way to access the primary key of the created child? Regards Marty ...

Loading Hibernate property from an external source (HashMap)

I have a Message object associated with a User object (user_from and user_to). I persist the Message instances into a database using Hibernate (with JPA annotations) and the user_id is persisted. The User object is also stored to the database, but when fetching messages I would like the User to be fetched from a Map in memory instead of...

HQL query, how to?

Hi, I am working query with little idea of what software I am dealing with and minimum knowledge HQL. What I am looking is, SELECT Entity1 FROM Entity AS Entity1 WHERE (EXISTS ELEMENTS(Entity1.config.dateTimeInfo.ntpConfig.server) ) But I want to set a condition saying WHERE count(ELEMENTS(Entity1.config.dateTimeInfo.ntpConfig.se...

Why does hibernate not find properties when I have hibernate.cfg.xml in my default package classpath?

I am having a bitch of a time getting this simple application working. I've got a configuration file in my default class path, using annotations with the correct class entries in the config file, and a default Session factory class that generated by the hibernate eclipse plug in tool. If I only rely on the default classpath config file, ...

What are the effects of disabling the redo logs in Oracle on Hibernate transactions?

If we disable the 'redo logs' of a tablespace in Oracle, will they impact Hibernate's transactions? These are the options present in the Oracle EM on a tablespace level: Enable logging Yes Generate redo logs for creation of tables, indexes and partitions, and for subsequent inserts. Recoverable No Redo log entries are smaller, the a...

Hibernate Entity sort column configuration

Is there a Hibernate configuration (hopefully an annotation on a classes mapped @Column field) that would let me sort a collection of entities associated with the loaded entity by a given column of that entity when a session.load(Entity.class, Id) is called? For example if I had an EntityA that contained a OneToMany association to an En...

Can Hibernate's @Version consider changes in related entities?

Hi! I have 2 entities: Parent and Child in a one-to-many relationship. The Parent is versioned, i.e. has a @Version field. My goal is to synchronize changes to both Parent and Child entities on the Parent's version. E.g. one thread updates the Parent and another one updates one of it's Childs, this should cause an OptimisticLockExcepti...

Un-committed database transactions and auto-increment columns

I encountered some curious behavior today and was wondering if it is expected or standard. We are using Hibernate against MySQL5. During the course of coding I forgot to close a transaction, I presume others can relate. When I finally closed the transaction, ran the code and checked the table, I noticed the following. All the times I...

How can I test wether persistence.xml has been found or not?

I have to test some things on a project which has been developed by others, but is new to me. They are using Hibernate as a JPA implementation. I got a virtual machine in which everything is set up, but when I want to start any Testclient (small console programs, no Unittesting). I always get the same error. Exception in thread "main"...

What are the advantages of using named queries under Hiberante Annotation

Are there any advantages of using named queries vs what we have? Looking at performance, usability, maintainability etc etc.... In our application we have defined our queries as such: private static final String SELECT_CODE_FOR_STORE = "select DISTINCT code from Code code " + "join code.codeDescriptions codeDesc " + "j...

Using Hibernate sequence generators manually

Basically, I want a way to access sequence values in a database-neutral way. The use case is that I have a field on an entity that I want to set based on an incrementing value (other than the id). For instance, say I have a Shipment entity. At some point after the shipment gets created, it gets shipped. Once it gets shipped, a manife...

Can't create foreign key

I'm trying to add a foreign key to an existing table, and was having issues. I figured that I had an error in my syntax, so I updated my hibernate.cfg.xml file to auto-update. As it turns out, hibernate had the same error. Here's my SQL to add the foreign key: alter table pbi add index FKEA3F7BDE9BAB051 (FK_idP), add constraint FKEA3...

Hibernate Security Apprehension: Hibernate vs. Stored Procedures

At the company that I work with, we often have to integrate with client’s infrastructure. Recently, after hearing that we use Hibernate, one client manifested following concern: Since user under which Hibernate connects to database has a direct access to tables and Hibernate generates SQL dynamically, then such user can do pretty mach an...

Hibernate 2nd level cache not caching committed entities

I'm wondering if it's possible for Hibernate second level cache (we're using EHCache) to allow an application to cache an Entity that has been comitted to the DB if it knows that no other applications are modifying the DB. My thought is that if I update record A, then I know the value of record A and should be able to cache that, JVM cl...

hibernate mapping file without all properties

I have a database containing approx. 200 tables. I use jboss-ide to automatically generate hibernate classes from the database using the File->New->Other->Hibernate->Hibernate Mapping file wizard of jboss-ide 1.6. the problem i'm facing is that the .hbm.xml file generated does not contain all the propertiese it's supposed to. what's als...

Good object structure for results of my Hibernate left outer join

I need to make an outer join query that retrieves all of the definitions and any properties they have associated with them that are associated with a certain company. I have two Hibernate models objects: class PropertyDefinition { @Id private Long id; @Column private String name; @OneToMany(mappedBy = "propert...

A Stackoverflow mapping (Hibernate)

Hi, Suppose a mapping like this one @Entity public class User { private Integer id private List<Info> infoList; @Id public getId() { return this.id; } @OneToMany(cascade=CascadeType.ALL) @JoinColumn(name="USER_ID", insertable=false, updateable=false, nullable=false) public getInfoList() {...