Given the following object model
class Test
{
...
public string Name {get;set;}
public IList<Test2> Collection {get;set;} //mapped with cascade="all"
}
class Test2
{
...
public string Name {get;set;}
}
and code sample
var test = new Test();
test.Collection.Add(new Test2(){Test=test,Name="1"});
//saving new entity with N...
Is it possible to create a criteria that lists all objects sorted by sope property of their children?
For example:
class Post {
User owner
}
Post.withCriteria {
order('owner.registerDate', 'asc')
}
It fails with message: Error 500: org.hibernate.QueryException: could not resolve property: owner.registerDate of: Post
What is ...
hello good people
i'm developping an application where all the pojos are exposed as interface but we map the real implementation class.we are using spring and JPA annotation.i'm about to test the one-to-one relationship and i'm having a light problem with the interface.
Caused by: org.springframework.beans.factory.BeanCreationExcepti...
Hi,
I have an integration test in my Grails application that fails when I try to save an entity of type Member
invitingMember.save(flush: true)
This raises the following exception
org.hibernate.AssertionFailure:
collection
[com.mycompany.facet.Facet.channels] was
not processed by flush() at
com.mycompany.member.MemberConn...
Methods invoked:
1. Struts Action
2. Service class method (annotated by @Transactional)
3. Xfire webservice call
Everything including struts (DelegatingActionProxy) and transactions is configured with Spring.
Persistence is done with JPA/Hibernate.
Sometimes the webservice will throw an unchecked exception. I catch this exception a...
I wrote a Hibernate interceptor :
public class MyInterceptor extends EmptyInterceptor {
private boolean isCanal=false;
public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[] arg3, Type[] arg4) throws CallbackException {
for(int i=0;i<100;i++){
System.out.println("Inside MyInterceptor(onSave) : "+entity.toS...
I'm trying to figure out how to generate a simple join that uses an 'or' clause contained within it, using HQL or Hibernate annotations. Here is an example of what I want the SQL to look like:
select *
from tableA
left outer join tableB
on tableA.id1 = tableB.id1
or tableA.id2 = tableB.id2
where ...
I know I can do straight SQ...
I have the following inheritance hierarchy.
@Entity
@Table(FRUIT)
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColum(name="FRUIT_TYPE",discriminatorType=STRING)
public class Fruit {
..
@Id
private FruitId id;
...
}
@DiscriminatorValue("APPLE")
public class Apple extends Fruit {
...
@ManyToOne
private FruitBowl bowl...
My question is very much like http://stackoverflow.com/questions/1068974/getting-the-return-value-of-a-pl-sql-function-via-hibernate
I have a function which does some modifications internally and it returns a value.
The original idea was to do something like this:
protected Integer checkXXX(Long id, Long transId)
throws Exception {
...
I can't seem to find any recent talk on the choice. Back in '06 there was criticism on Hibernate Search as being incomplete and not being ready to compete with Compass, is it now? Has anyone used both and have some perspective on making the decision.
I am developing a web app in Java in my free time, its just me so I'm looking to cut co...
I have two domains that have a many-to-many relationship. Example:
class LibraryUser {
String name
static hasMany = [ checkedoutBooks : Book ]
}
class Book {
String title
static hasMany = [ usersWhoCheckedItOut : LibraryUser ]
}
However I now want to record the time of checkout and store this in the already existing j...
Hi,
I am using Hibernate3.jar in our App.While trying to fetch some objects using the foreign key we used the order-by clause on the collection as shown below
< set name="children" cascade="all-delete-orphan" lazy="true" order-by="SORT_ORDER_ID asc,lower(CHILD_NAME) asc,lower(FIRST_NAME) asc,lower(LAST_NAME) asc">
Now i ...
By default if I create a field in an entity like:
@NotNull
boolean myBoolean;
And I let Hibernate auto-create my tables. What Oracle data type will this map to?
...
Basically the idea is to use the same hibernate mapping files for two different underlying databases. In production the underlying database is MySQL5 and for testing purposes I'd like to use Apache Derby - in order to avoid setting up and maintaining various MySQL databases for testing purposes.
I hoped that just switching the DataSour...
Hello good people i came accross a weird behaviour in my test.I'm using JPA hibernate annotation with spring.
let say i have an Class MyObject and it's property email is marqued
@Column(name="EMAIL", length=100, unique=true)
private String email;
i prepare for what i need to be in the database in the setup of this class MyObjectDAOImp...
Hi
Is it possible in hibernate to print generated sql queries with real values instead of question marks?
How would you suggest to print queries with real values if its not possible with hibernate api?
Umar
...
I created an hibernate interceptor :
public class MyInterceptor extends EmptyInterceptor {
private boolean isCanal=false;
public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[] arg3, Type[] arg4) throws CallbackException {
for(int i=0;i<100;i++){
System.out.println("Inside MyInterceptor(onSave) : "+entity....
I have two classes A and B. Many B's can have association with a single A, hence a many-to-one relationship from B to A. I've mapped the relationship like:
<class name="A" table="tbl_A">
<property name="propA" column="colA"/>
</class>
<class name="B" table="tbl_B">
<property name="propB" column="colB"/>
<many-to-one name="a" class...
hello good people
So far i've been working with only a case with 2 properties with and as logical operator so i use LogicalExpression like so
Criterion eqRef = Restrictions.eq("referenceID", referenceId);
Criterion eqType = Restrictions.eq("verificationType", type);
LogicalExpression and = Restrictions.and(eqRef, eqType);
this time al...
I do a query that returns a list of entities. How can I retrieve the entities from a ScrollableResults:
Session s = ....;
Query q = s.createQuery("....") # returns 100000s rows
ScrollableResults sr = q.scroll();
sr.scroll(45999); # just a number
Employee employee = ???
How do I get an employee in the last line of code
...