3

Can I write this query using API criteria or am I stuck with HQL?

 3 years ago
source link: https://www.codesd.com/item/can-i-write-this-query-using-api-criteria-or-am-i-stuck-with-hql.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Can I write this query using API criteria or am I stuck with HQL?

advertisements

I have the following query which I would like to write using the criteria api of NH.

select status, count(1) from (select distinct Status, post_id from post_statistics) tbl group by status

each post_id can exist multiple times in post_statistics

id post_id status 1 1 open 1 1 edit 1 1 open 1 2 open

so the query should return the following results:

status count open 2 edit 1

thx in advance.


mappings, classes? if i'm thinking right, with a proper mapping this would effectively be something like

(pseudo-HQL)

select stat.Name, count(stat.Posts) from status stat

Tags nhibernate

Related Articles

How do I write this query using the laravel query builder?

I'm on laravel 5.1 using postgres as the DB. I have a fiddle here in case it helps understand my issue: https://www.db-fiddle.com/f/5ELU6xinJrXiQJ6u6VH5/4 with properties as ( select properties.*, json_agg(property_fields.*) as property_fields from p

How to write this query using joins?

i have a table campaign which has details of campaign mails sent. campaign_table: campaign_id campaign_name flag 1 test1 1 2 test2 1 3 test3 0 another table campaign activity which has details of campaign activities. campaign_activity: campaign_id is

Can I modify this query using a WITH clause?

I have written the following query in order to achieve the following: 1) Select all regulatory languages that do not have a specified ID. 2) Link those regulatory languages based on a hierarchy field (RL_ID_DEFINED - this field is the ID of the paren

How can I write a query inside select in the rails

How can I write this query in Ruby on Rails? Query inside a select SELECT id, company_id, (SELECT name FROM companies WHERE id = referred_to_id) AS name FROM referrals WHERE company_id = 21 @referrals = Referral.select('id, company_id, (SELECT name F

Rails Refactoring Block in Views - Can I Write This More Effectively?

I'm trying to setup logic for my tables in rails. Basically its a timesheet application and what I want to do is set it up show it shows green if you hit your goal. Yellow if you are almost there. And red if you aren't even close. The code I have bel

How can I accelerate this query that joins a table on itself?

We have a `users' table that holds information about our users. One of the fields within this table is called 'query'. I am trying to SELECT the user id's of all users that have the same query. So my output should look like this: user1_id user2_id co

The most concise way to write this query to add a time to a date

I have a field with a DateTime. I want to ignore the time on that field and add a specified hour. Here is an example of what I'm looking for, where @h could be any value from 0 to 23. (And I'm using getdate() instead of the field from my table for si

How can I optimize this query?

How can I optimize this query if given the following query returns either all entries in the table or entries that match only up to current date ? btw: The Query is targeted to a Oracle Linked Server on MS Sql 2005 as an Inline function.. Do not want

How can I make this query SQL injection proof?

How can i make this query sql injection proof? $sql=mysql_query("SELECT * FROM updates ORDER BY item_id DESC LIMIT 16"); while($row=mysql_fetch_array($sql)) { $msg_id=$row['item_id']; $message=$row['item_content']; } Or can someone show me some

A better / more efficient way to write this query

I am trying to count the number of records in a table. The table is called affiliations and only has 4 columns (2 of which are foreign keys) I want to count the number of records where the affiliated column is 0 and the business_id is related to a pa

How can I rewrite this query in Google BigQuery without the error exceeding

I get a resources exceeded error when I run the following query , how can I rewrite this query to avoid that error ? SELECT XXX_lnaourj_ID, XXX_DR_Tma_LC, XXX_CR_Tma_LC, XXX_Amount_LC, XXX_TLAffect_LC, XXX_Entry_Desc, XXX_DocType, XXX_TCode, XXX_Comp

Positioning css with display or float, can I get this structure using the display property

Given this HTML: <div id="div1"> <div id="div1a"></div> <div id="div1b"></div> <div id="div1c"></div> <div id="div1d"></div> </div> <div id=&q

How to write this query in the active records of codeigniter

How to write this query in codeigniter active records select a.parent_cat_id,a.parent_cat_name, b.child_cat_id,b.child_cat_name, c.sub_child_cat_id,c.sub_child_cat_name FROM parent_categories a,child_categories b,sub_child_categories c WHERE a.parent

How can I write this infix statement to postfix?

How can I write this statement: 9-3/(1+2) ... from infix to postfix?9-3/(1+2) First would be (1+2) since it has the highest order of operation. -> 1 2 + Then 3 divided by the result... -> 3 1 2 + / Then 9 minus the result.... -> 9 3 1 2 + / -

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK