How would you express the following Criteria query in HQL?
var idArray = new int[] { 1, 2, 3, 4, 5 };
Session.CreateCriteria(typeof(Foo))
.Add(Expression.In("Id", idArray)
.List<Foo>();
I am aware of that there is an "in" keyword in HQL, but as I understand it that keyword is for use with subqueries rather than something like...
Suppose I have an object like
public class Handle {
private String handle;
public Handle(String name) {
this.handle=name;
}
public String toString() {
return this.handle;
}
}
that is a property of some POJO that I would like to persist with Hibernate. How do I define the mapping for my POJO such tha...
I'm trying to set up a Hibernate filter with annotations. I would like to specify it in a base class and make all sub classes use it but whenever I try to enable it, Hibernate fails to find the filter. Is it possible at all to inherit filter annotations?
...
I am using Spring MVC 2.5, and I am trying to get a JSTL form object to load from a GET request. I have Hibernate POJOs as my backing objects.
There is one page directing to another page with a class id (row primary key) in the request. The request looks like "newpage.htm?name=RowId". This is going into a page with a form backing object...
In using Hibernate's JPA implementation, I noticed an interesting optimization behavior. Within the same transaction, the initial JPA query's WHERE clause is used for subsequent queries involving the results of the initial query.
For example, person has lastName and a set of owned books.
// (1) get person by last name
Query q = entityM...
Is there any real issue - such as performance - when the hibernate object model and the database physical model no longer match? Any concerns? Should they be keep in sync?
Our current system was original designed for a low number of users so not much effort was done to keep the physical and objects in sync. The developers went about ...
Is it a bad idea to use the annotations from the
javax.persistence package
instead of using the
org.hibernate.annotations annotations
I know that using javax.peristence does introduce yet another dependency. But if I ignore that, what are the pros/cons?
...
I am working with a large, old database and i now try to access it with hibernate instead of SQL.
One of the larger Problems with this is the use of "0" and "-1" (meaning "NULL") in foreignKeys without constraints.
I had much of the code generated, but i add the joins manually. Like this
@OneToMany(fetch = FetchType.EAGER)
@JoinColum...
I'm working with hibernate search and I think I'm almost done implementing it except for this one issue. The problem is I don't get any results if the fields I pass into the MultiFieldQueryParser include the class name. I get the expected results when the fields just include the field name.
String[] fields = {"bar.title", "foo.descript...
We have an existing and working database created from hbm mapping files.
We want to create some new tables for an optional feature.
One option is that these new tables always exist but we would prefer for the tables and POJOs to only be created on request.
My issue is that these tables/POJOs have dependancies on existing tables/POJOs....
I am using hibernate as my ORM solution, with EHCache as the Second Level (Read-Write) cache.
My question is: Is it possible to access the Second Level cache directly?
I want to access this: http://www.hibernate.org/hib_docs/v3/api/org/hibernate/cache/ReadWriteCache.html
How can I access the same ReadWriteCache that is being used b...
I have a VO class which has the getter and setter of another VO class too. For example:
Class DocumentVO{
PrintJobVO job;
PrintRunVO run;
String id;
getters and setters..
}
Now I have a requirement to use the Native SQL Query using spring hibernate. When I want to map the ids I have a problem. My query is,
select {r.*},{d...
I am creating database Entities in my Java application and trying to rationalize between using an Integer or a Long as the class type of the "id" field. I am using Hibernate as my ORM which, in turn, will map this field to a column in the HSQLDB database.
My struggle is this: a Long is obviously larger and will handle a greater number o...
How do you get a OneToOne item to automatically remove with JPA/Hibernate? I would expect simply setting the OneToOne item to be null in the class that contains would be smart enough to allow Hibernate to delete it.
Given a simple object, simplified:
@Entity
public class Container {
private Item item;
@OneToOne(cascade=Cascad...
I am trying to create a form to edit an existing database row. I am using the Spring MVC form tag to auto bind the html to a form backing object. The row has a many to many relationship with another table, which I am trying to represent with a multiple select box using the form:select tag;
<form:select path="rules">
<form:options items...
In my schema there are a few redundant columns used to speed up report queries. For example, the purchase total of a sale is saved in the "purchase_total" column of the "sale" table, yet in the model, it is calculated dynamically by adding up the sold price of each item purchase in the sale. This value can be retrieved by calling the "g...
My Java application uses db sessions, via Hibernate.
What I want to do is somehow, when I create a session in my app, is to identify that session as an 'application' session. The reason is that I wish (via a before trigger) to restrict the updates that users can make to a table, while giving the application carte-blanche to do what it l...
I assume that the following is a no no(?)
> public Criteria createCritera(Class<?> persistentClass) {
> ...//creation of session object etc.
> session.beginTransaction();
> Criteria crit = session.createCriteria(persistentClass);
> session.getTransaction().commit();
> session.close();
>
> return crit;
}
...
Abridged version of my schema:
utility_company
id int not null -- PK
name varchar(255) not null
utility_settings
utility_id -- FK to utility
use_magic tinyint(1) not null default 0
There is a one-to-one mapping between these two tables. Setting aside the fitness of this design, I want to Map the data in both of these tables to one o...
When I try to use the ThreadLocalSessionContext in the following way:
Session hsession = HibernateUtils.getSession();
ThreadLocalSessionContext.bind(hsession);
// do stuff
hsession.close();
I do this for every single Struts Action. Is there something I am doing wrong, causing me to get the following error?
[ThreadLocalSessionContext]...