nhibernate « Query « JPA Q&A





1. NHibernate, Sum Query    stackoverflow.com

If i have a simple named query defined, the preforms a count function, on one column:

  <query name="Activity.GetAllMiles">
    <![CDATA[
      select sum(Distance) from ...

2. (N)Hibernate Selecting Constants in Query    stackoverflow.com

does anyone know if you can do something like this using the (N)Hibernate criteria api:

Select 1 AS obj.Property0, obj.Property1, obj.Property2 from Class
Baiscally I want to select a constant value for one ...

3. How to a write a Criteria query with multiple joins involved    stackoverflow.com

I'm trying to code the following HQL query using the Criteria API:

var userList = _session
                .CreateQuery("select ...

4. How to construct this NHibernate query    stackoverflow.com

I have a one-to-many relationship. I would like to construct this query: Give me all the parents that have only one child and for this child child.Type=X Since I 'm learning, please show ...

5. NHibernate Query Help    stackoverflow.com

I have the following code which works fine. However, I only want to return rows where eventID = 5; Where can I add criteria to this query?

tx = session.BeginTransaction();

    ...

6. NHibernate: HQL and UserTypes as query paramaters    stackoverflow.com

I'm using a database that has a weird date format. I wrote a UserType to transfer standard .NET DateTime to/from the weird format and it works fine. I've normally used ICriteria ...

7. NHibernate: hql to criteria query - help needed    stackoverflow.com

I have this hql query, which works perfect:

            select m 

          ...

8. How to query: Select games in categories A, B and C    stackoverflow.com

I'd like to know how to effectively run a query such as:

select game from Game game 
inner join game.Categories cat
where cat.Name in ('A', 'B')
This gives me games with categories A or ...

9. NHibernate query problem    stackoverflow.com

these are my entities (simplified):

public class IdentificationRequest
{
    private int id;
        private ICollection<IdentificationRequestStateHistoryItem> stateHistoryItems;

        public ...





10. HQL query problem    stackoverflow.com

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)
      ...

11. NHibernate Query across multiple tables    stackoverflow.com

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 ...

12. Hibernate simple criteria query solving problem    stackoverflow.com

I'm stuck with a very simple criteria query problem:

sess    .createCriteria(user.class, "user")
        .user_c.add(Restrictions.eq("user.status", 1))
        .user_c.createAlias("user.userCategories","ucs")
 ...

13. NHibernate HQL queries    stackoverflow.com

How to write HQL queries using NHibernate. What namespaces will I have to included so that everything works fine. Actually I have 2 tables Ticket and Trip and I wanta count ...

14. HQL query to get parent of an object    stackoverflow.com

I'm an absolute hql newbie so bear with me... How do I write a hql query to retrieve the parent object of a child object? I've got an object/table TrackClass with a one-to-many ...

15. NHinerbate Query problem - Join Query with Non - primarykeys    stackoverflow.com

I am new to Nhibernate, I'm trying to use nhibernate in a project and i wanted to convert the following sql query to Nhibernate HQL? Is this query possible in Nhibernate ...

16. Fluent Nhibernate - HQL select problem    stackoverflow.com

I am new to NHibernate. I am using Fluent Nhibernate and when I run a simple query I get null results. Here is my configuration: Fluent Configuration:

Fluently.Configure().Database(MsSqlConfiguration.MsSql2008
       ...





17. NHibernate query ( hql vs criteria )    stackoverflow.com

I have an hql query string

"from MyTable table
 where table.StartTime + table.Duration >= : startTime
 and   table.MyId = : id"
How can i write this without hql in NHibernate ...

18. With NHibernate 2.1, how does one grab the first item in a collection using HQL to be used in the select clause?    stackoverflow.com

Assume that I have a class Product:

public class Product
{
    public virtual string Name { get; set; }
    public virtual IList<Order> Orders { get; set; }
}
and ...

19. select in Nhibernate by HQL    stackoverflow.com

I have some mapping:

<class entity-name="Person" table="table1">
<id column="Id" type="long" name="Id"/>
<set name="Address">
<key column="Person_id"/>
<one-to-many class="Address"/>
</set>
<property column="Id" name="Id" type="long"/>
<property column="Last_Name" name="LastName" type="string"/>
<property column="First_Name" name="FirstName" type="string"/>
<property column="Education" name="Education" type="string"/>   
</class>

<class entity-name="Address" table="table2">
<id column="Id" type="long" ...

20. NHibernate: getting object model with HQL using a join on table    stackoverflow.com

I am having difficult time trying to figure out how to get a mapped object using a join on a table (not mapped table). Tables:

DataForm: (Id, AliasName (FK), ...)
Customer: (Id, ...)
CustomerAliases: (PK ...

21. Whats wrong with my Nhibernate HQL query?    stackoverflow.com

I have this

public List<TableA> GetRecords(List<string> keys)
    {
        const string query = "FROM TableA WHERE `Key` = :keys";
     ...

22. NHibernate get next Birthdays    stackoverflow.com

I have a table which contains a column Birthday of Type DateTime. Now I should select with HQL all Persons which Birthday is in the next 10 days or was in ...

23. Querying two tables, from code    stackoverflow.com

I have two tables. the first table: Employee

IdEmployee
Name
LastName
The second table: CommentsEmployee
IdComment
IdEmployee
Note
make consultation with the IdEmployee in the two tables, get Name, IdComment, and Note from C# Tables are of type SQL was trying
DetachedCriteria criteria1 ...

24. Multi-table NHibernate query    stackoverflow.com

I have an object graph that looks like this:

class A ()
{
   int id;
   IEnumerable<B> bees;
}

class B()
{
   int id;
   A a;
   C ...

25. Creating a "where in" HQL query    stackoverflow.com

I am having trouble writing a HQL query which uses a "where in" clause. Simplified classes look like this:

class Parent
{
    public virtual Int64 Id { get; private set; }
 ...

26. NHibernate QueryOver equivalent of HQL With?    stackoverflow.com

What is the QueryOver API equivalent of a WITH clause in HQL? I have not been able to find one.

27. my instance of an object changes via a linq 2 hibernate select query    stackoverflow.com

I'm trying to execute a linq query,, but in middle of transaction it seems that the instance I'm working with has been changed and is not what its suppose to be

 ...

28. How to write this query in hql    stackoverflow.com

I have this linq query in nhibernate

var b = session.Query<Table1>().FetchMany(x => x.Table2).ThenFetchMany(x => x.Table5s).ToList();
That gets rendered as
select table1x0_.Id        as Id0_0_,
    ...

29. Caching Query for NHibernate    forum.hibernate.org

Hi, We are using NHibternate with .Net 1.1 and are having some data related issues. We're experiecing some invalid data being returned from hibernate. Issue reolves around two users inadvertently sharing the same Isession instance. Could this result in data related to the first user being cached and return to the second user. For each entity request mentioned above unique object ...