So far, I always prefered to use Hibernate directly rather than JPA 1.0, because JPA was lacking some of the important features I needed and Hibernate provided: Criteria API, second level cache, unidirectional OneToMany and a few others.
Now, with the advent of JPA 2.0 and all the new features that come with it and that were initially m...
I'm currently moving a (working) app from using EclipseLink to Hibernate JPA, mostly it's gone quite smoothly, but I'm finding one thing that I can't explain, and also can't think of any good search terms!
Basically, I have four entities, with one-to-many relationships forming a chain:
EntityA has a list of EntityB's, each of which has...
Is there a way to programatically get Hibernate configuration parameter values, if I have access to a SessionFactory object?
I would like to list the configuration in a GUI view, for debuging purposes.
...
I am trying to map a JPA (using Hibernate) one-to-one relationship with a inheritance strategy TABLE_PER_CLASS. Here is an example:
@Entity
public class DrivingLicense {
@OneToOne(targetEntity = Human.class, cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@JoinColumn
private Human human;
@SuppressWarnings("unchecked")...
I am using Hibernate/JPA to execute native PostGIS queries. The problem with these queries is that they need parameters that are not of the classical X = 'value' form.
For example, the following lines crash
String queryString = "select * from Cell c where ST_DWithin(c.shape, SetSRID(ST_GeomFromEWKT('POINT(:lon :lat)'),4326), 0.1)";
...
I have BaseEntity class which is a superclass of all JPA entities in my application.
@MappedSuperclass
public abstract class BaseEntity implements Serializable {
private static final long serialVersionUID = -3307436748176180347L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", nullable=false...
I'm developing a JEE6-application, using JPA 2.0 and Hibernate 3.5.2-Final as the Provider (and MySQL 5.1.41). My Application Server is Glassfish V3.0.1.
I already have a working CRUD-app with some entities and relationships.
Now i added an (really simple) entity with the name "Group". The entity class looks like this:
package model
//...
Hi,
I have a problem removing the parent entity from the database. The code looks like this:
public class Parent implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchTy...
I'm using Hibernate 3.5.2-FINAL with annotations to specify my persistence mappings. I'm struggling with modelling a relationship between an Application and a set of Platforms. Each application is available for a set of platforms.
From all the reading and searching I've done, I think I need to have the platform enum class be persisted a...
I have a Java class (Entity) with a set of named queries. When the Spring tries to inject the related bean, it is not finding one of the queries.
As example:
@NamedQueries({
@NamedQuery(name = "Query1", query = "..."),
@NamedQuery(name = "Query2", query = "..."),
@NamedQuery(name = "Query3", query = "..."),
...
I'm using Hibernate JPA.
Suppose I have these classes:
AbstractPerson
|--> ConcreteEmployee
|--> ConcreteCustomer
Is there any way to make the concrete classes have independent IDs?
I'm using InheritanceType.TABLE_PER_CLASS.
...
I have a wicket page , which contains two Spring-managed beans , one is DAO , another is Service Object :
public class MergeAccountsPage extends WebPage
{
@SpringBean
private MergeEmailDao mergeEmailDao;
@SpringBean
private MergingService mergingService;
}
The MergingService's implementation's methods are mostly annotated wit...
I have some OneToMany child collections in my domain classes that may grow over time to hold hundreds or (very likely) thousands of instances. However, often times the only thing the parent really needs is the "first" child or the "last" child or the "biggest" child. Having the parent instance loop through a large collection of objects...
How can I order JPA to set a MySQL database column with text content as case sensitive by default upon creation?
...
I'm using NetBeans 6.8 and Glassfish Enterprise Server 2.1.1 ((v2.1 Patch06)(9.1_02 Patch12)) (build b31g-fcs).
I created a servlet and used Netbeans code generation features to imlement persistence using TopLink (JPA1).
When I try to create an Entity Manager with the following code:
EntityManagerFactory entityManagerFactory=Persiste...
Hello,
I have a Spring application which uses Hibernate on a PostgreSQL database. I'm trying to store files in a table of the database. It seems it stores the row with the file (I just use persist method on EntityManager), but when the object is loaded from the database I get the following exception:
org.postgresql.util.PSQLException: ...
In a legacy database, I have three tables: Users, Workgroups, and UsersWorkgroup. UsersWorkgroup stores what role a user has in a workgroup.
Here are the relevant code snippets:
@Entity
@Table(name = "users_workgroup")
public class UsersWorkgroup implements Serializable {
private static final long serialVersionUID = 1L;
@Embedde...
I'm using JBoss 4.2.3 and I deployed two ears called triad-1.0.ear and reportservices-1.0.ear, the thing is that I want to use the entity manager of the project triad in the project reportservices. This is the architecture JBoss follows:
triad-1.0.ear:
triad-core-1.0.jar:
META-INF:
...
When I use the maven-hibernate3-plugin (aka hbm2ddl) to generate my database schema, it creates many database constraints with terrifically hard-to-remember constraint names like FK7770538AEE7BC70 .
Is there any way to provide a more useful name such as FOO_FK_BAR_ID ?
If so, it would make it a tad easier to track down issues in the lo...
Env: Seam 2.2.0, JPA, Hibernate 3.3.x, ehcache-core 2.0.1
Here are some observations on using a cache along with Hibernate. We are already using the 2nd level cache but not quite comfortable with the response times.
The third option mentioned in the above reference (Direct access to EHCache, only use Hibernate on a cache miss: 20 secon...