I am creating a method that can create filter understood by NHibernate (by filter i mean a set of ICriteria object for example) from my abstract filter object.
public static IEnumerable<ICriterion> ToNhCriteria(this MyCriteria criteria)
{
// T4 generated function
// lots of result.Add(Expression.Or(Expression.Eq(),Expression.Eq)) ...
Hi guys,
I have two table a "Module" table and a "StaffModule" I'm wanting to display a list of modules by which staff are present on the staffmodule mapping table.
I've tried
from Module join Staffmodule sm with ID = sm.MID
with no luck, I get the following error
Path Expected for join!
however I thought I had the correct jo...
I have HQL like this:
from Table1 t1 where t1.name not in (select t2.name from Table2 t2 order by t2.date limit 10)
The problem is it doesn't understand limit keyword. Is there a way to run such query without splitting it into two subqueries?
...
I want to write an insert query in Grails. I have tried all possible combinations but cant get the syntax correct. Can anybody please help?
class Person {
int age
String name
}
i tried the following:
Person.executeUpdate("insert into Person values (20,"ABC")")
p.s.:Please do not mention using save()
...
I have the following SQL that I am having problems converting to HQL. A NPE is getting thrown -- which I think has something to do with the SUM function. Also, I'd like to sort on the subselect alias -- is this possible?
SQL (subselect):
SELECT q.title, q.author_id,
(SELECT IFNULL(SUM(IF(vote_up=true,1,-1)), 0)
FROM vote WHER...
I have a database that is being used as a sort of version control system. That is, instead of ever updating any rows, I add a new row with the same information. Each row also contains a version column that is a date timestamp, so the only difference is the new row will have a more recent timestamp.
What I'm having trouble with is writin...
Hi everyone (my first post!),
I have an HQL question (in Groovy/Grails) I was hoping someone could help me with.
I have a simple Asset object with a one-to-many Tags collection.
class Asset {
Set tags
static hasMany = [tags:Tag]
}
class Tag {
String name
}
What I'm trying to do in HQL:
A user passes in some tags in params...
I'm trying to determine how to find/retrieve/load objects efficiently in terms of a.) minimizing calls to database and b.) keeping the code as elegant/simple as possible (i.e. not writing hql etc.).
Assume you have two objects:
public class Foo {
Bar bar
String badge
}
public class Bar {
String name
}
Each Foo has a bar...
Hello,
We are getting a "could not execute native bulk manipulation query" error in HQL
When we execute a query which is something like this.
String query = "Select person.id from Person person where";
String bindParam = "";
List subLists = getChucnkedList(dd);
for(int i = 0 ; i < subLists.size() ;i++){
...
Hi everyone
Iam trying to this in HQL:
select A.a A.a1, B.b,B.b1 from A,B
where A.x=B.x;
It is simple to realize the join with sql but when returninig in HQL I find a problem.
would you please give me the HQL syntax for the join
Thanks for help.
...
I write same query with two approach by using NHibernate:
1- by using HQL like below
public long RetrieveHQLCount<T>(string propertyName, object propertyValue)
{
using (ISession session = m_SessionFactory.OpenSession())
{
long r = Convert.ToInt64(session.CreateQuery("select count(o) from " + typeof(T).Name + " as o" + "...
I've got a hibernate query I'm trying to get working but keep getting an exception with a not so helpful stack trace. I'm including the code, the stack trace, and hibernate chatter before the exception is thrown. If you need me to include the entity classes for MessageTarget and GrpExclusion let me know in comments and I'll add them.
...
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...
I tried session.createSQLQuery("ALTER TABLE People MODIFY address VARCHAR(1000);").executeUpdate();
but this throws org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
After a lot of googling, the recommendation is to use HQL instead of SQL query to do bulk updates. Not sure how to use HQL to a...
How can I order by a specific property order in HQL?
For MySQL I can use: SELECT * FROM question q ORDER BY q.status IN ("DONE", "NO_ACTION"), q.status IN ("NEW","SAVED"), q.created DESC
but HQL doesn't allow in in order by.
Am I missing something? Is there some other way around this problem?
Thanks
...
did i encounter a hibernate bug or do i have an error i dont see:
select enty.number from EntityAliasName enty
where enty.myId in
(
select cons.myId from Consens cons where cons.number in
(
select ord.number from Orders ord where ord.customer = :customer
and ord.creationDate <
(
select max(ord.crea...
Hi all,
I have two tables and respective classes in java.The mapping in the HBM.xml is as follows :
<class name="com.hcl.spring.db.sample.model.Parts" table="MARM_PARTS">
<id name="partNo" type="int" column="PART_NO">
<generator class="increment" />
</id>
<property name="imageId" column="IMAGE_ID"></property>
<property name="groupId"...
I need to write a query to get an object between a range of time, currently the query looks like this:
Timestamp from = ...
Timestamp to = ...
getHibernateTemplate().find("from " + Person.class.getName() + " ml where ml.lastModifiedOn>="+from.toString()+" and m1.lastModifiedOn<=" + to.toString());
However, this doesnot work for ob...
Hello everybody,
I working on a project with Hibernate and we need to replace Hibernate with some "home made persistence" stuff.
The idea is that the project is big enough, and we have many HQL queries.
The problem is with the queries like
select a,b from table1, table2 on t1.table1=t2.table2
Basically all joins are not supported by ...
Hi there!
I have the following hql query:
from Admin a where a.genericTable is null or (a.genericTable.allowInsertion = true or a.genericTable.allowInsertion is null)
The problem is that the result set is excluding all entries that are comprised on filter: a.genericTable is null
Does anyone knows why?
Thanks!
...