hibernate

Long running transactions with Spring and Hibernate?

The underlying problem I want to solve is running a task that generates several temporary tables in MySQL, which need to stay around long enough to fetch results from Java after they are created. Because of the size of the data involved, the task must be completed in batches. Each batch is a call to a stored procedure called through JD...

Hibernate Stored Procedure Results

I am forced to manage an auto-increment field from code. I've decided to write a stored procedure to do this for me. The idea is to have a procedure that inserts a new row and returns the auto-incremented value to Java so I can work with it further. The following is what I have so far. I don't know what to change to fill the gaps to ...

Hibernate Lazy Loading Proxy Incompatable w/ Other Frameworks

I've come across several instances where frameworks that take POJOs to do some work crap-out with proxied hibernate beans. For example if I xml annotate a bean for framework X and pass it to framework X it doesn't recognise the bean because it is passed the proxied object - which has no annotations for framework X. Is there a common s...

No unique bean of type [javax.persistence.EntityManager] is defined

I am using JUnit 4 to test Dao Access with Spring (annotations) and JPA (hibernate). The datasource is configured through JNDI(Weblogic) with an ORacle(Backend). This persistence is configured with just the name and a RESOURCE_LOCAL transaction-type The application context file contains notations for annotations, JPA config, transaction...

[hibernate - jpa] @CollectionOfElements without create the apposite table

EDIT Hi all. WHAT I TRY TO GET I want a table that represents a list of personal details, this table is called PERSON and must have this columns: ID NAME SURNAME STREET ID_CITY Well, i already have a table in my db that contains all municipalities of my country, this table is called MUNICIPALITY and has this column...

Jpa subclass mapping

I am making a POS like system. I wonder how to map subclass using JPA (this is for my DAO). Product class has product details and OrderProduct class has information about the Product and details about the order. @Entity @Table(name="products") public class Product implements Serializable{ @Id @Column(name="id") @GeneratedVal...

Is there a way to tell JPA/Hibernate to transform column names from camcel case to _'s?

Is there a generic way to tell JPA/Hibernate to transform all column names of the form: emailAddress to the form: email_address ? I'd rather not have to use a @Column annotation for hundreds of columns. I hope someone thought of this ;) ...

Why use your application-level cache if database already provides caching?

Modern database provide caching support. Most of the ORM frameworks cache retrieved data too. Why this duplication is necessary? ...

database design in MySQL and Hibernate

Hi everybody, I am new to the all technologies just familiar with the introduction of both... I am planning to make railway reservation project, in that I want to use MySQL with Hibernate... So I have one sample design of database to make a project, I need help to combine the MySQL with Hibernaete... Database Design... trains (ID,name,...

Hibernate query on four tables

I have three tables. question ( forumId as FK) answer (questionId as FK) forum forum member (forumId as FK) There can be multiple forums so i want to add a method that returns me all answer from a member in a given forum. I dont know what is the hibernate query i can do. To get the list of answer bound to the given member i do this ...

Hibernate @DiscriminatorColumn and @DiscriminatorValue issue

I have this parent class: @Entity @Inheritance(strategy = InheritanceType.JOINED) @Table(name = "BSEntity") @DiscriminatorColumn(name = "resourceType", discriminatorType = DiscriminatorType.STRING, length = 32) public abstract class BaseEntity { and the subclass @Entity @Table(name = "BSCategory") @DiscriminatorValue("Category") pub...

hibernate criteria filtering on a set of enum values

Hi I'm using Hibernate 3.2 with a 1.6 JDK and Mysql 5.0 I'm trying to use the criteria api to put together a dynamic filter. However when I add a Restriction on a Set of Enums that is a property of my Criteria object I get a org.hibernate.exception.GenericJDBCException. my code is like this: public class FollowUp { ... public...

Multiple HBM files with multiple classes for the same table.

Hi, Can you have 1 table be referred to by 2 different HBM's mapped to 2 different classes (they are unrelated, basic classes, no inheritance). I know it may be bad practice because of duplication but it has to do with code maintenance. I'm trying to avoid removing one of the classes. Thanks, ...

sequence generators are getting ignored

I'm getting the following error while saving a object. However similar configuration is working for other model objects in my projects. Any help would be greatly appreciated. @Entity @Table(name = "ENROLLMENT_GROUP_MEMBERSHIPS", schema = "LEAD_ROUTING") public class EnrollmentGroupMembership implements Serializable, Comparable,Auditabl...

Does there exist a tool for DB schema migration where schema are specified using Hibernate ?

I am used to Django South http://south.aeracode.org/, which allows schema and data migrations for Django projects. Does there exist a similar tool for Hibernate projects ? ...

Hibernate Criteria API: count and group by with result in Map

The Car entity is mapped to a database table with 2 columns: ID and Color. CarDao has the following method: Map<Color, Integer> countByColor(); If we have 3 red cars and 2 blue cars in the database table, the method returns a map with 2 keys (red and blue) and the corresponding count (3 resp. 2). I would like to do this with the Cri...

Getting Hibernate to generate indexes on foreign keys

I am using Hibernate 3.3.2 in a fairly large project with PostgreSQL 8.4 using the PostgreSQLDialect. The way we have our relationships set up, we end up doing a lot of searching on the Foreign Key attributes of our tables. For performance reasons, I would like to have Hibernate add Indexes to the all of the foreign key columns when ...

copy child collection to another object

Hi everyone, I have a one-to-many relationship between Part and Params (a "Part" has many "Params). I'm trying to do something naive like this: Part sourcePart = em.find(Part.class, partIdSource); Part destPart = em.find(Part.class, partIdDest); Collection<Param> paramListSource = sourcePart.getParamList(); destPart.setParamList(par...

Hibernate - component class not found

Does anyone know what this is all about: component class not found with Hibernate? I got this error How can i solve this issue..? Initial SessionFactory creation failed.org.hibernate.MappingException: component class not found: EventGeofenceId ...

Hibernate Criteria and row count restriction

Hi, i have two entities named Parent and Child, linked in a one-to-many relationship. The Child entity has a boolean isStudent property. How do i get, using the Hibernate Criteria API, all the Parent entities that have at least one Child with isStudent = true? I was trying to use a Projection object to count all the parents that have...