Hi all,
Fairly specific question here, but it's been bugging me for a day now:
I'm using Hibernate Core, Annotations & Validator on PostgreSQL 8.3.
I have the following classes setup:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Entry {
@EmbeddedId
protected EntryPK entryPK;
@ManyToMany
priva...
We're in the process of planning a large, enterprise application. We're focusing our efforts on evaluating hibernate after experiencing the pains of J2EE.
It looks like the new JEE API is simpler. I've also read some good things about Hibernate and iBatis. Our team has little experience with any of the frameworks.
There are 5 main co...
With HQL I can use dynamic instantiation like this:
select new ItemRow(item.Id, item.Description, bid.Amount)
from Item item join item.Bids bid
where bid.Amount > 100
Now I need to create my queries dynamically with the Criteria API. How can I obtain the same results that I would have obtained with HQL, but using the Criteria API?
Th...
I am currently in need of a high performance java storage mechanism.
This means:
1) I have 10,000+ objects with 1 - Many Relationship.
2) The objects are updated every 5 seconds, with the most recent updates persistent in the case of system failure.
3) The objects need to be queryable in a reasonable time (1-5 seconds). (IE: Give me...
I'd like to use Hibernate's criteria api to formulate a particular query that joins two entities. Let's say I have two entities, Pet and Owner with a owner having many pets, but crucially that association is not mapped in the Java annotations or xml.
With hql, I could select owners that have a pet called 'fido' by specifying the join in...
I worked a lot with Hibernate as my JPA implementation. In most cases it works fine! But I have also seen a lot of pitfalls:
Remoting with persisted Objects is difficult, because Hibernate replaces the Java collections with its own collection implementation. So the every client must have the Hibernate .jar libraries. You have to take c...
Hi,
I have a Java webapp using Hibernate and MySQL. If the site isn't used for a few days, the MySQL connection goes stale, and I am met with the following exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
From experience using...
Hi guys, I've just started learning Struts and I'm trying to be marketable for a good job as a Java programmer. My next decision would be choosing which to learn next, Spring or Hibernate?
Also do you guys have any suggestions or tips for me to be good? Thanks in advance!
...
I've the following many to many relation: File 1 --- * File_Insurer * --- 1 Insurer. I'm trying to query this relation using the Criteria API (Active Record) to get Files that meet ALL specified Insurers (Get all Files where Insurer.Id == 2 AND Insurer.Id == 3).
Mapping files (parts):
File
[HasAndBelongsToMany(typeof(Insurer),
Table =...
@Id
int master_id;
@Id
int id;
........this is not working:
User user= (User) session.load(User.class, new Integer(master_id), new Integer(id));
...
My app needs to block sleep/hibernate mode. I have the code in place, but after successfully catching the WM_POWERBROADCAST message, neither PBT_APMQUERYSUSPEND nor PBT_APMQUERYSTANDBY are being caught successfully. Interestingly, the PBT_APMRESUMECRITICAL and PBT_APMRESUMEAUTOMATIC messages are being caught by my app.
Bottom line quest...
All APIs in Hibernate are from 1.4 and are thus not using java generics.
So I wonder how "safe" the following is: (preconditions: name column is of datatype String, or atleast compatible to String)
@SuppressWarnings("unchecked")
public List<String> getAll() {
Query q = session.createQuery(
"select name from Customers");
...
MySQL seems to have an 8 hour time out on its connections. I'm running multiple WARs in Tomcat utilizing Hibernate for ORM. After 8 hours (i.e. overnight), I get broken pipes when it picks up an idle connection.
I've already traced through the code and made doubly sure I commit or roleback all transactions.
Here is my hibernate.cfg.x...
The application when developed is using a single database and the spring configuration is as follows.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
...
I receive the following exception when Im trying to alter my @ID in an @Entity.
identifier of an instance of com.google.search.pagerank.ItemEntity was altered from 1 to 2.
I know that im altering the primary key in my table. Im using JPA-annotations.
I solved this by using this single HQL query: update Table set name=:newName where n...
Hi
I'm trying to access the current hibernate session in a test case, and getting the following error:
org.hibernate.HibernateException: No
Hibernate Session bound to thread, and
configuration does not allow creation
of non-transactional one here at
org.springframework.orm.hibernate3.SpringSessionContext.currentSession(S...
I have a common User / Role setup, with a user_role join table. I'm trying to use Spring's HibernateTemplate to mass delete all locked users like this:
getHibernateTemplate().bulkUpdate("delete from User where locked=?", true);
If the user being deleted does not have any roles (no record in the user_role table), then everything goes f...
I have a table DEAL and a table DEAL_TYPE. I would like to map this code:
public class Deal {
DealType type;
}
public enum DealType {
BASE("Base"), EXTRA("Extra");
}
The problem is that the data already exist in the database. And I'm having a hard time mapping the classes to the database.
The database looks something like that...
I am trying to add validation for message payload (which are json). I am using Jackson Json processor for data binding, which works quite well for me, using bean methods and occasional annotation or two.
But beyond data binding, I would like to declaratively validate actual values: and specifically I prefer annotations over any externa...
Hi i an using Hibernate tool with eclipse ganymede 3.4.1 . Now when i create the .hbm.xml file using the code generation of Hibernate tool,it is automatically creating a composite key.
I am adding the code over here :
but ...