I have created a DetachedCriteria that is retrieving estates that have the isApproved and isPublished set to true. It is defined in this way:
DetachedCriteria activePublishedCriteria = DetachedCriteria.forClass(Estate.class)
.add(Restrictions.eq("isApproved", true))
.add(Restrictions.eq("isPublished", true))
.setResultTransf...
Hi,
The first part is HOW TO PROJECT COLLECTIONS?
Can We apply projections on collection elements?
For e.g
class User{
private address List<Address>;
}
class Address{
private String city;
private String state;
}
Now can I just load the address attribute of User class? Using code like :
criteria.setProjection(Proje...
I'm trying to put an entity in a different maven project. In the current project I have:
@Entity
public class User {
...
private FacebookUser facebookUser;
...
public FacebookUser getFacebookUser() {
return facebookUser;
}
...
public void setFacebookUser(FacebookUser facebookUser) {
this.facebookUser = facebookUser;
}
Then Fa...
Hi everyone,
I am currently working with Hibernate Envers. My problem is the following :
How to delete entries in the audit table related to the entity I want to delete?
My entity has no relation with other entities.
I figured out that I have to do that in onPostDelete method of my custom listener :
import org.hibernate.envers.event...
Hi,
In a table, we are using the type xml for a field. But the mapping with hibernate with string doesnt work.
It seems that we have to write a custom type to store it by using postgres driver utils.
I cant find this mapping on google and here.
Anyone have ever write a mapping to the xml type for hibernate & will share it here please...
I have top level entities TRACK, MEDIA_GROUP and MEDIA, each with an integer primary key. I also have a join table from TRACK to MEDIA_GROUP which is 1:1 and MEDIA has a FK column into MEDIA_GROUP. I'm trying to find a way in hibernate to map a collection of Media directly into the Track object, bypassing the creation of a MediaGroup o...
I'm asking both Hibernate and NHibernate groups because I'm thinking this may be a common issue seen on both.
What does it usually mean when you call a saveOrUpdate on a child object and...
1) If it is an insert everything works fine.
2) If it is an update its wiping out the parent ID in the database.
More info: problem is really occur...
Hello,
I've read somewhere that when a session is flushed or a transaction is committed, the session itself is closed by Hibernate. So, how can i reuse an Hibernate Session, in the same thread, that has been previously closed?
Thanks
...
I have a problem with Hibernate Native Query. I have one SELECT that selects array slice (PostgreSQL database).
The problem is that hibernate recognizes the following part: ":300" from "SELECT my_array[1:300]..." as named parameter and I get the following exception: Not all named parameters have been set.
I tried to escape the colon (:...
I have been trying to migrate a database from sybase to Mysql.
This is my approach:
Generate pojo classes from my sybase database using hibernate in eclipse
Use these pojo classes to generate the schema in mysql database
Then somehow migrate the data from sybase to mysql
I guess this approach should work??? Please let me know if the...
Hi,
I'm currently trying to create a pair of Hibernate annotated classes to load (read only) from a pair of tables in a legacy system. The legacy system uses a consistent (if somewhat dated) approach to keying tables. The tables I'm attempting to map are as follows:
Customer CustomerAddress
-------------------------...
Say I have two entities Foo and Bar where Foo has-many Bar's,
class Foo {
int ImportantNumber { get; set; }
IEnumerable<Bar> Bars { get; set; }
}
class FooDTO {
Foo Foo { get; set; }
int BarCount { get; set; }
}
How can I efficiently sum up the number of Bars per Foo in a DTO using a single query, preferrably only with the Cr...
I use Hibernate3 and Hibernate Tools 3.2.4 to generate hbm.xml and java files and I want to use List instead of HashSet(...). I've tried to modify the hbm.xml files, putting list instead of set. Is there any way to specify to hibernate tools that I want to generate automatically a list not a HashSet?
This is an exemple:
Java class
publ...
I am using annoted Hibernate, and I'm wondering whether the following is possible.
I have to set up a series of interfaces representing the objects that can be persisted, and an interface for the main database class containing several operations for persisting these objects (... an API for the database).
Below that, I have to implement...
Hello...
I write an application based on an already existing database (postgreSQL) using JPA and Hibernate. There is a int2-column (activeYN) in a table, which is used as a boolean (0 => false (inactive), not 0 => true (active)). In the Java application i want to use this attribute as a boolean. So i defined the attribute like this:
@E...
Working with JPA / Hibernate in an OSIV Web environment is driving me mad ;)
Following scenario: I have an entity A that is loaded via JPA and has a collection of B entities. Those B entities have a required field.
When the user adds a new B to A by pressing a link in the webapp, that required field is not set (since there is no sensib...
I'd like to have a combined query for two persistent classes.
In HQL this could be achieved by the select clause,
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
In the above example, Family is a conbined class with DemesticCat as its c...
Looked at many forums but haven't found answer...Simple stuff, method annotated with @PostLoad newer gets invoked...added listener via @EntityListeners but problem remains. I'm using SessionFactory based configuration.
...
I'm trying the following:
MyResult.java :
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityResult;
import javax.persistence.SqlResultSetMapping;
@Entity
@SqlResultSetMapping(name = "myResults", entities = {@EntityResult(entityClass = MyResult.class)})
publi...
I have a column in a PostgreSql database that is defined with type boolean[]. I wish to map this to a Java entity property using Hibernate 3.3.x. However, I cannot find a suitable Java type that Hibernate is happy to map to. I thought that the java.lang.Boolean[] would be the obvious choice, but Hibernate complains:
Caused by: org.hiber...