We're developing a WebSite that's intended to have several requests per second.-
Our current environment is JavaEE, JBoss 4.2.3, Struts2 for MVC, JPA with Hibernate as ORM and Postgres as DB.-
This is the scenario: whenever a request comes to any of the pages, some action checks for information in the DB to fill the requested page (tha...
So in my persistence.xml I turned on hibernate.generate_statistics.
<property name="hibernate.generate_statistics">true</property>
My question is.. how do I access them? Where do the statistics go?
...
I am having trouble with getting some caching to work with hibernate exactly the way I would like. I created some example code to replicate this problem I am having.
I have one object that contains instances of itself. For instance, a Part that is made up of more Parts.
I really need to minimize the select statements that Hibernat...
I'm currently using Eclipselink, but I know now days most JPA implementations have been pretty standardized. Is there a native way to map a JPA entity to a view? I am not looking to insert/update, but the question is really how to handle the @Id annotation. Every entity in the JPA world must have an ID field, but many of the views I have...
Let's say that I'm new to JPA, is there a way to get my skills up to speed? Are there any good tutorials?
...
I'm seeing performance problems with retrieving multiple instances of objects that have many relationships with other objects. I'm using Spring and Hibernate's JPA implementation with MySQL. The issue is that when executing a JPA query, Hibernate does not automatically join to other tables. This results in n*r + 1 SQL queries, where n is...
It's a well known fact, that Oracle treats empty strings as null.
However, I'm having an issue because of this behaviour due to JPA's caching.
First I persist using JPA (Toplink Essentials) an entity, which has an empty string as one field. Oracle converts this value to null when it stores it.
However, when I fetch the entity, JPA see...
I have two tables joined together with entities like this (entities anonymized, and trimmed of irrelevant properties):
Email
- Email_ID
- Title
- Body (hibernate uses a Body_ID field here)
Body
- Body_ID
- Body_Text
I'd like to retrieve all Email entries that do not have an associated Body row (ie, Body_ID is null). What HQL wou...
I'm using Hibernate's JPA implementation with MySQL 5.0.67. MySQL is configured to use InnoDB.
In performing a JPA query (which is translated to SQL), I've discovered that using the IN clause is slower than performing individual queries. Example:
SELECT p FROM Person p WHERE p.name IN ('Joe', 'Jane', 'Bob', 'Alice')
is slower than fo...
I have 2 entities: car and wheels (oneToMany) and I want to retrieve my car, with all the wheels and (this is the tricky part) ordered by wheels.location.
Select c from Car LEFT JOIN FETCH c.wheels order by c.wheels.location doesn't work:
"illegal attempt to dereference collection".
Any idea how to do this and if this is possible in HQ...
I'm building an application using a JPA object model, and creating several Data Access Objects to interact with that model. I'm finding that I'm repeating a lot of code (essentially CRUD) between different Data Access Objects. The only thing that differs are the targeted JPA classes.
I was wondering if anybody knows of an abstraction li...
Hi,
I've got 2 entities in JPA: Entry and Comment. Entry contains two collections of Comment objects.
@Entity
public class Entry {
...
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@IndexColumn(base = 1, name = "dnr")
private List<Comment> descriptionComments = new ArrayList<Comment>();
@OneToMany(fetch = FetchTy...
I have a stateless bean resposible for persisting entities to a database. This stateless bean is called by a message bean's onMessage method. The wired thing is that on the first message everything works fine, but on the next message the method responsible for persisting is invoked outside a transaction, even though the method is annotat...
My entity has a named query which looks like this:
@NamedQuery(name = "Person.find", query = "select p from Organization p where p.name=:NAME")
In my code I want to set the query cache hint:
query.setHint("eclipselink.cache-usage", "CheckCacheThenDatabase");
If I try to get whole result list:
List<Person> result = query.getResultL...
I've got a String column defined with
@Column(length = 4000)
The attribute contains log information and can be longer than the defined length. In this case, the field can be safely truncated without throwing an error message.
I'd like to find out the determined length of the column in the DAO class for the pojo so that I can truncat...
Hi,
I'm using Hibernate's JPA impl to model some tables. I'm having trouble mapping a table that:
Has no primary key
Has a unique index on 4 columns, 3 of which can be nullable
I tried to hack it and define the index as a composite Id, but since some columns are nullable this is not working properly. Is this possible with JPA/Hibern...
Hi gang,
I have a pretty simple JPA @ManyToMany relationship set up in my application. A Product is a part of one or more OrderSystems. Each OrderSystem can have many Products. It's a typical many-to-many relationship.
The problem I'm fighting with is this: If I use orderSystems.remove() to remove a reference from a Product to an Or...
I need 3 entities: User, Contract (which are a many to many relation) and a middle entity: UserContract (this is needed to store some fields).
What I want to know is the correct way to define the relationships between these entities in JPA/EJB 3.0 so that the operations (persist, delete, etc) are OK.
For example, I want to create a Use...
I have two entities:
@Entity
public class Customer implements java.io.Serializable {
...
@OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
private Set<CustomerOrder> customerOrders;
...
@Entity
public class CustomerOrder implements java.io.Serializable {
....
private double cost;
@ManyToOne
@JoinCo...
Hibernate is continuing to spew SQL traces to stdout, and I can't figure out how to change a Hibernate configuration property when it's hidden behind a JPA adapter. This is the Spring bean for the entityManagerFactory:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<...