Hi, I need to add paginator for my Hibernate application. I applied it to some of my database operations which I perform using Criteria by setting Projection.count().This is working fine.
But when I use hql to query, I can't seem to get and efficient method to get the result count.
If I do query.list().size() it takes lot of time and I t...
I am trying to get a list of Products that share the Category.
NHibernate returns no product which is wrong.
Here is my Criteria API method :
public IList<Product> GetProductForCategory(string name)
{
return _session.CreateCriteria(typeof(Product))
.CreateCriteria("Categories")
.Ad...
Hi all, I have map the entities in .hmb.xml and define attribute for all entity in classes.
I have some basic accomplishment and get all the record using below code.
public List<DevelopmentStep> getDevelopmentSteps()
{
List<DevelopmentStep> developmentStep;
developmentStep = Repository.FindAll<DevelopmentStep>(new Orde...
This really puzzled for hours, I searched all over the internet, but got no working solution. Can someone point where the problem is ... thanks !
I created my own dialect class
public class MySQLDialectExtended : MySQLDialect
{
public MySQLDialectExtended()
{
RegisterFunction("date_add_interval", new SQLFunctionTemplate(...
Why Nibernate HQL can not handle the following query:
from Deal D where (D.ApprovalDate + INTERVAL 1 Year) < current_timestamp() < (D.RenewalDate + INTERVAL -1 Year)
knowing that INTERVAL and YEAR are keywords in MySQL, so this is kind of mixing Sql within Hql (unless Hql can handle date functions like so and I don't know) . The dia...
The problem here consists of translating a statement written in LINQ to SQL syntax into the equivalent for NHibernate. The LINQ to SQL code looks like so:
var whatevervar = from threads in context.THREADs
join threadposts in context.THREADPOSTs
on threads.thread_id equals threadposts...
There is sql statement
select distinct create_date from articles
Is it possibele to write this statement using HQL?
Cheers!
...
I am very unfamiliar with SQL/HQL , and am currently stuck with this 'maybe' simple problem :
I have two many-to-many Entities , with a relation table :
Car , CarProblem , and Problem .
One Car may have many Problems ,
One Problem may appear in many Cars,
CarProblem is the association table with other properties .
Now , I want to ...
In hibernate I want to run this JPQL / HQL query:
select new org.test.userDTO( u.id, u.name, u.securityRoles)
FROM User u
WHERE u.name = :name
userDTO class:
public class UserDTO {
private Integer id;
private String name;
private List<SecurityRole> securityRoles;
public UserDTO(Integer id, String name, List<SecurityRole>...
Hello all,
I can't find what's going on with the following nHibernate HQL.
here's my VB.Net code:
Return _Session.GetNamedQuery("PersonAnthroSummary").SetInt32(0, 2).UniqueResult()
My Named Query:
<sql-query name="PersonAnthroSummary">
select New PersonAnthroSummary( Anthro.Height, Anthro.Weight ) from PersonAnthroContac...
Hi all,
I'm using this hql query for my filters. Query perfectly working except width (string) part.
Here is the query,
public IList<ColorGroup> GetDistinctColorGroups(int typeID, int finishID, string width)
{
string queryStr = "Select distinct c from ColorGroup c inner join c.Products p " +
...
I have a HQL query:
query = select item.itemNumber from items item where item.stock>0 and item.price<100.00
i like to parse this query and convert it into a tree structure:
AST queryTree = parse(query);
than i like to iterate through the nodes, change some values, and convert the tree back to a string represenation:
Iterator<ASTNo...
I am using NHibernate, and am trying to figure out how to write a query, that searchs all the names of my entities,
and lists the results. As a simple example, I have the following objects;
public class Cat {
public string name {get; set;}
}
public class Dog {
public string name {get; set;}
}
public class Owner {
public string...
The NHibernate Book discusses very briefly queries that fetch several queries at the same time. They only show how to do this with the native CreateSQLQuery command. Are there any options for fetching multiple entities simultaneously using the criteria or hql APIs?
...
Is it possible to access the relationship table when doing HQL statement?
As an example, I have 3 tables: account, commitment, account_commitment. It was generated using these domains:
class Account {
static hasMany = [ commits : Commitment ]
String name
}
class Commitment {
static hasMany = [ actors : Account ]
String ...
Suppose a Table per subclass inheritance relationship which can be described bellow (From wikibooks.org - see here)
Notice Parent class is not abstract
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Project {
@Id
private long id;
// Other properties
}
@Entity
@Table(name="LARGEPROJECT")
public class ...
I'm having trouble figuring out how to do a "join" in Groovy/Grails and the return values I get
person = User.get(user.id)
def latestPhotosForUser = PhotoOwner.findAll("FROM PhotoOwner AS a, PhotoStorage AS b WHERE (a.owner=:person AND a.photo = b)", [person:person], [max:3])
latestPhotosForUser isn't a list of PhotoOwners. It's a lis...
I have a relationship like this:
class E {
string name
hasMany = [me:ME]
}
class M {
float price
}
class ME {
E e
M m
int quantity
}
And I'd hate to iterate to achieve this: "obtain the sum of the quantity in ME times the price of the corresponding M for a given E".
Any hints on how to implement it using GORM/HQL ?
Thanks...
Hi
I have the following SQL query:
select c.id
from (select id from customers) c
This query has no practical value - I simplified it greatly for the purpose of this post.
My question: is it possible have a subquery in the from clause using HQL. If not, can I perhaps query the customers first, kinda like a temp table in sql, and then...
I have the following database schema :
Two tables, books and tags, with n-m relationship.
Books - Tags
We can have for example the book 1, with tags {A,B,C}, and book 2, with tags {A}.
I would like to select the books according to a list of tags.
For example : selected tags list : {A,B}
-> book 1
My idea was to use the MINUS SQL fu...