hibernate

hibernate workflow

Hi I'm trying to write a program with Hibernate. My domain is now complete and I'm writing the database. I got confused about what to do. Should I make my sql tables in classes and let the Hibernate make them Or create tables in the database and reverse engineer it and let the hibernate make my classes? I heard the first optio...

select in HQL (hibernate)

I have a table in mysql which has just on record. when I execute following hql query in netbeans HQL I got the following answer which is correct: query: from Customer as cust response: CustomerID PhoneNumber MainAddress SubAddress RequesstNumber Name 1 22334455 Niavaran shahrake naft 3 ...

Hibernate L2 Cache on cluster

Q1: Am I right that only this vendors support Hibernate L2 cache on cluster? Terracotta for Hibernate (comercial) SwarmCache (not released since 2003) JBoss Cache 1.x JBoss Cache 2 Q2: Are there are any alternatives to Hibernate L2 cache? (Maybe some DB caching?) ...

Hibernate EntityManager + JOTM: transactions are not used

I am trying to integrate together JOTM and Hibernate EntityManager to test my EJBs in a transactional manner environment but out-of-container. My test looks like the following: Start JOTM Put JOTM's UserTransaction into JNDI Create and configure StandardXADataSource Put the DataSource into JNDI Configure hibernate and create EMF Creat...

Annotations - JAR dependencies

Although I'm a fan of using annotations, I do have concern over the dependencies they create on third party jars. For the purpose of this question, I'm referring specifically to Hibernate or JPA annotations on domain model classes. In reality, I want my domain model to consist of simple POJOs without any dependencies on a persistence ...

Hibernate configuration on runtime

Hi again. I have hibernate.cfg.xml file. <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url"></property> <property name="connection.username"></property> <property name="connection.password"></property...

Update of of Composite Entity fails

I have Person entity which has composition with Location Entity @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE }) @Cascade( {org.hibernate.annotations.CascadeType.SAVE_UPDATE }) public Location getLocation() { return location; } And Location Entity has Name as Id @Id public String getName()...

hibernate mapping class

I have a project which it's domain contain following classes: Courier Customer Food Order Customer PrimitiveElement ResturantCustomerFacade ResturantOrderFacade And My database also has these tables: Courier Customer CustomizedFood CustomizedPrimitivePrice FoodType Order PrimitiveType ValueType and the classes which hibernate makes...

HQL 1 to many count() question

I'm trying to write a query in HQL, and I'm having some trouble with it. It's probably not too difficult, but I'm pretty awful at query languages in general and HQL in specific. Basically, there are three tables, Owners, Pets, and Toys, whose classes look like this: public class Owner { long ownerId; List<Pet> pets; } public class P...

HIbernate schema update error

Hi everyone, During the startup of Jboss server, I get the following stacktrace. I wonder why JPA is trying to alter tables that seem to be fine and how to get passed these ERROR messages. Thanks 2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table BDPARAMS add constraint FK61733C48FA34BFDC f...

Lazy Hibernate JPA using SOAP

I have a bunch of annotated, interrelated POJOs that I want to create/modify/search over SOAP. I made a utility to eagerly load every detail of each POJO and create an XML string so I can send the entire POJO graph as a search result. Even though the graphs are very small (less than three nodes), the eager loading took a very long time...

Count function in HQL causing null results?

I have the following HQL query that is attempting to return 2 object instances as well as an aggregate count based upon a 3rd object instance. SELECT client, clientCampaign, count( formData ) FROM FormData as formData JOIN formData.deliveryResults as deliveryResults JOIN formData.leadForm as leadForm JOIN leadForm.campaignForms a...

Hibernate or JDBC

I have a thick client, java swing application with a schema of 25 tables and ~15 JInternalFrames (data entry forms for the tables). I need to make a design choice of straight JDBC or ORM (hibernate with spring framework in this case) for DBMS interaction. Build out of the application will occur in the future. Would hibernate be overki...

jpa how to create new entity with same id as parent entity (JOINED Inheritance)

Hi folks, my question is very similar to http://stackoverflow.com/questions/1118873/changing-the-type-of-an-entity-preserving-its-id, but instead i´m using InheritanceType.JOINED instead of Table_per_class. This means i don´t to change any table, just to create a new subclass, with the same id as the superclass. To summarize, I have a...

Hibernate session and garbage collector

An object with hibernate session data member when garbage collected, is session's jdbc connection closed? In other words is leaving closing session to garbage collector bad idea? ...

Hibernate not saving collection of values

Okay, I've used Hibernate in several projects now but I did not learn its intricacies before using it. I started with looking at codes that used JPA Annotations and integrated with Spring and everything worked well. But now that I want to teach basic Hibernate to my students and I'm in the process of creating an example and using the doc...

Grails Hibernate Session Read Only

Hi. I have two grails servers: Server - has read/write access to the database Web - has read-only access to the database, and for every write it sends a request to the server The problem: How do I make the Web's domain objects read only in one place (config file) for the entire run of the application, instead of writing caching: 'rea...

Transactional L2 cache in Hibernate

Q1: What does "transactional" strategy guarantee? Q2: What is the difference between "transactional" strategy and "read/write" strategy with JTA as transaction manager (specified by property). Q3: What if I specify "transaction" strategy for some entity in a .hbm.xml file and then will use L2 cache which does not support "transaction"...

How to map inner object using Hibernate/JPA without xml/annotation?

We have an object, A, which contains another object, B. We have Hibernate calling a stored procedure to query the data and populate instances of A. We're using the @NamedNativeQuery annotation with teh resultClass property set to A.class. This works great except that the instances of B are loaded lazily, as if Hibernate can't figure o...

Persist collection fields with hibernate

Using hibernate, how can I persist a class with a List<String> field? Consider the following entity class: @Entity public class Blog { private Long id; private List<String> list; @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } public List<String> getList(...