I would like to perform the following query in HQL:
select count(distinct year(foo.date)) from Foo foo
However, this results in the following exception:
org.hibernate.hql.ast.QuerySyntaxException:
expecting CLOSE, found '(' near line
1, column 27
It seems that hibernate does not allow using functions as arguments to it...
In the Hibernate online documentation, under section 7.2.3 One-to-many, it's mentioned, that:
unidirectional one-to-many association
on a foreign key is an unusual case,
and is not recommended. You should
instead use a join table for this kind
of association.
I would like to know why? The only thing that comes to my mind is...
Hi all,
I'm using Hibernate 3.1.1, and in particular, I'm using HQL queries.
According to the documentation, Hibernate's queries are polymorphic:
A query like: from Cat as cat returns instances not only of Cat, but also of subclasses like DomesticCat.
How can I query for instances of Cat, but not of any of its subclasses?
I'd li...
Hi all,
On my way in understanding the transaction-type attribute of persistence.xml, i came across an issue / discrepency between hibernate-core and JPA-hibernate which looks weird.
I am not pretty sure whether it is a missing implementation with JPA of hibernate.
Let me post the comparison between the outcome of JPA implementation ...
I want to copy all data of a specific table from database1 to database2. In my system i have access via hibernate to the domain object from database1, i don't have to transform the data-structure. i have only a native jdbc connection to database2.
whats the best solution to make this groovy script very generally to support all kinds of...
Hello,
I was doing simple things with hibernate, as I have to learn it for a project. I created this simple example:
package hibtests;
import hibtests.beans.newBean;
import org.hibernate.Session;
/**
*
* @author dario
*/
public class Main {
public void test(){
Session session = NewHibernateUtil.getSessionFactory().ge...
Has anybody used ajax in hibernate project ? Any pointers, help will be appreciated.
...
This is a similar problem to "Hibernate @OneToMany without a separate join table", in that I need a @OneToMany relationship without a join table. However, I would also like to not define the inverse relationship. Removing the inverse seems to result in a join table being automatically generated... is there a workaround for this?
...
I have two entities, lets call them A and B, which have a ManyToOne mapping to another entity, say C
So I typically have something like this:
a1->c
a2->c
b1->c
Lots of A's and B's pointing to the same C.
How do I get Hibernate to remove c when I remove the last a and b?
...
Hi all,
To avoid XA overhead I prefixed some table names from project A and rolled it out to be inside the same mysql database as project B so I can use the same connection - and hope to get full atomicity etc.
Project A and B though have very different session factory configs. I have a HibernateTransactionManager configured for projec...
HQL noob here. How do I re-write this HQL query without using the exists clause. In SQL I can just join VisitorProfileField table and Visitor table and add the conditions of the exists using an AND.
But in plain HQL I am not able to get past some syntax violation I guess. Your help is much appreciated.
"select distinct v from Visitor...
Hi,
I have three entities ClassA, ClassB and ClassC.
ClassA {
...
@Id
@GeneratedValue
@Column(name = "a_id")
private long id;
...
@OneToMany(cascade={CascadeType.ALL})
@JoinColumn(name="a_id")
private List<ClassB> bbb;
...
}
ClassB {
...
@ManyToOne
private ClassC ccc;
...
}
ClassC {
...
private String name;
...
}
I...
I have two tables "Station" and "Route". Route can contain many stations and every station can be a part of the different routes. The logical solution is to create a table with 'station_id' and 'route_id' fields and there are lot of examples on the internet how to organize all of this stuff with hibernate. But I need to store the order n...
I'm having trouble starting a transaction with Hibernate and MySQL while running in JUnit. I'm getting a HibernateException which states: "No TransactionManagerLookup specified". I believe this error is because I don't have a proper configuration setting for hibernate.transaction.manager_lookup_class.
I see that under the namespace of ...
I found JPA, or alike, don't encourage DAO pattern. I don't know, but I feel like that, especially with server managed JTA managers.
After adequate hands-on using DAO pattern, I started designing JPA based application around that pattern. But it doesn't fit in, IMO. I tend to lose quite a features of JPA and all.
Well, suppose you fire...
Hello,
I'm starting to work with hibernate. I'm quite confused about HQL joins... they are really different from, say, mySQL joins... In fact if I have two tables like Parking and Auto I would do:
select *
from Parking
left join on Parking.pid = Auto.parkingId
or something the like. Instead in hibernate I will have a Parking class alr...
Hello,
I've to use more than one database together (on the same connection... ) via mysql. I want to use hibernate, but all I can find around is to use two sessionfactories. Now the problem is: how can I do mappings like one-to-many among different sessionfactories... seems not possible as I have to put mapping in one configuration and I...
I am doing some big queries on my database with Hibernate and I sometimes hit timeouts. I would like to avoid setting the timeout manually on every Query or Criteria.
Is there any property I can give to my AnnotationConfiguration that would set an acceptable default for all queries I run?
If not, how can I set a default timeout value ...
when using the @GeneratedValue Annotation in Hibernate, and adding a new Entity to DB it has the id 1 ... n .
Is is it possible to set the first value, so it would get the id e.g. 10000 ... n ?
...
I have an AbstractDao implemented by every Dao of my database.
public abstract class AbstractDaoImpl extends HibernateDaoSupport {
(...)
public void delete(T pEntity) throws FerdeDaoException {
try {
this.getHibernateTemplate().delete(pEntity);
} (...)
}
....
Bascially the flushMode seems to be at AUTO.
What do i ...