hibernate

How does Spring fit into my application architecture?

I'm currently rebuilding an existing PHP application using Java. I therefore have an existing frontend GUI and an existing database schema that I'm working with. Here is the technology stack I'm working towards: jQuery, client-side Wicket, front-end Spring, ??? Hibernate, ORM MySQL, database Before reading about Spring in both Wicke...

Is it possible to set Hibernate's "default" variable name mapping?

I'm looking for a way to set the "default" mapping that Hibernate applies to a variable name in a Java object to query it against the database. At the moment we are using the inline javax.persistence markup to manually set column names, but since we have a rigid naming policy for our database it would be nice to be able to just skip on t...

Using Hibernate with RCP and PostgreSQL

Our team is building an RCP application using PostgreSQL for DB. We are evaluating the usage of Hibernate. Our project has the following constraints : 1) The project is a small extract-and-run-in-any-system type RCP application which is mostly used by non-technical users with a minimum setup needed. The application should have a low mem...

Bypass GeneratedValue in Hibernate (merge data not in db?)

My problem is the same as described in [1] or [2]. I need to manually set a by default auto-generated value (why? importing old data). As described in [1] using Hibernate's entity = em.merge(entity) will do the trick. Unfortunately for me it does not. I neither get an error nor any other warning. The entity is just not going to appear i...

Hibernate Projections.sum() over an enum

I need some help with Hibernate Projections. I have a class called Activity with a property "duration" which is an Enum. Duration is a Integer field on the Oracle Database. I have annotated the enum. @TypeDefs({ @TypeDef( name = "Duration", typeClass = GenericEnumUserType.class, parameters = { ...

Hibernate Criteria - Return parent records that have child records

All, I'm probably over-analyzing this problem, but... Given table "A" with two one-to-many relationships "A1" and "A2", return all records in table "A" that have at least one child record in either table "A1" or "A2"... I'm not necessarily interested in knowing what the child data is, but rather that I just have child data. Thanks! ...

Hibernate: Mixing dynamic (Map-based) and static (Bean-based) mapping

Hi! I'm working on a program to store and manage test results. Tests have properties like date, duration, and also results. However, some tests measure pressure, others temperature... I hope you get the idea. So, not every test has the same attributes. My first thought was to extract the test results out of the test table into individua...

Problem on JPA: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

Hey there everyone ... I´m using JPA with SPRING and mySQL and I´m having problems while removing an entity... I am doing this: @PersistenceContext private EntityManager em; ... @Transactional public void delete(Long id) { em.flush(); OwnerEntity e = em.getReference(Entity.class, Long.valueOf(id)); if (e == null) throw new Ex...

Hibernate Validator 4+. Get all Constraints associated with a class

How can I get all constraints for a class. For instance I have class A { @NotNull private SomeBean field; } When I call: ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintDescriptor<?>> descriptor = validator.getConstraintsForClass(formClass).ge...

Hibernate Reverse Engineering with Eclipse and MySql

I'm having the hardest time getting Eclipse to connect and reverse engineer from a MySQL5 database. I can see Eclipse connecting to my MySQL database and can even see the tables through the "Data Source Explorer" view but when I try it after creating Hibernate Console and Configuration files, I get the error: org.hibernate.console.Hibe...

seam-gen reverse engineering

hi guys, I just realized that seam-gen creates wrong entities for one to many relationships by default. First it uses HashSet instead of List, how can I change that? This is my schema: category(category_id, category_description, workgroup_id) subcategory(subcategory_id, subcategory_description, category_id) This is what should be cre...

Hibernate Mapping a Map

Coming from NHibernate, I've tried to do something like this in Java (first example): http://ayende.com/Blog/archive/2009/06/03/nhibernate-mapping-ndash-ltmapgt.aspx I have the following code: public class Box implements Serializable { private Long boxId; private Map<String, String> properties; public String getProperty(String ...

How can I learn to make realistic assumptions about database performance?

I'm primarily a Java developer who works with Hibernate, and in some of my use cases I have queries which perform very slowly compared to what I expect. I've talked to the local DBAs and in many cases they claim the performance can't be improved because of the nature of the query. However, I'm somewhat hesitant to take them at their ...

Retrieving Polymorphic Hibernate Objects Using a Criteria Query

In my model I have an abstract "User" class, and multiple subclasses such as Applicant, HiringManager, and Interviewer. They are in a single table, and I have a single DAO to manage them all. User: @Entity @Table(name="User") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn( name="role", discriminatorTy...

Spring/Hibernate testcase error

I am using spring and hibernate and currently making test case for database test and i am getting this error Error: Before Test CaSe SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1e91a4d] to prepare test instance [com.Test.TestClass@bdc9b3...

Wicket - which ORM?

Hi, I'm looking for an easy-to-use and intergrate ORM for Wicket application. I was thinking about Hibernate. Is it a good choice? What are the possible problems with Wicket/Hibernate? Any other suggestions are welcome. Thanks for any help. ...

spring, hibernate, log4j for centralized error catching

I am using JSF 2.0, Spring, Hibernate and I need to implement Log4J for centralized error catching. Can anybody help? ...

Which tables must be defined as Discriminated Entities on Hibernate?

Hi all, I want to develop a blog and image gallery system. My db schema likes below; IMAGE {table}  | ARTICLE{table}    | COMMENT{table} -------------------|------------------------|----------------------- PK id;              | PK id;                    | PK id; PATH String;   | FULLTEXT String  | ENTITY_ID {IMAGE_ID, ARTICLE_ID...

Hibernate - One to many relationship and orphanRemoval cascade

Hi, I have a basic one to many relation parent / child like in the chapter 21 of Hibernate references book. The cascade is only from child to parent (persist cascade only because I don't want to delete the parent if I delete a child). When I add a child to the parent and I save the child, I have a TransientObjectException... @Entity pu...

Trouble with hibernate's named query

I am new to hibernate and I am having some trouble with the named query annotation. My code is as follows and is more or less generated by NetBeans The BasicUser class: package wmc.model; import java.io.Serializable; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Colu...