I'm using NHibernate with Lambda Extensions and I can't figure out how to phrase a specific kind of query.
My application lets users tag other users in pictures. So there are Picture objects, and each Picture has one or more Tag objects, and each Tag object has one User object.
I'm implementing a search feature. Given a search string, ...
I am trying to recreate something like the following SQL using NHibernate criteria:
select Range, count(*) from (
select
case
when ent.ID between 'A' and 'N' then 'A-M'
else 'Other'
end as Range
from Subject
) tbl
group by tbl.Range
I am able to create the inner select as follows:
session.CreateCri...
Hi everyone,
I want to write the following query as a Hibernate Criteria query:
select
to_char(nvl(ol.updated_datetime, ol.created_datetime), 'dd/mm/yyyy'), sum(discount_price)
from order_line ol
where nvl(ol.updated_datetime, ol.created_datetime) between to_date('05-may-10') and to_date('30-may-10')
group by to_cha...
I have an nHibernate query using Criteria, and I am trying to cast a string to bool in the query itself. I have done the same with casting a string to int, and that works well (the "DataField" property is "1" as a string):
var result = Session
.CreateCriteria<Car>()
.Add(Restrictions.Eq((Projections.Cast(NHibernateUtil.Int32,
...
Does anyone have a good example for how to do a findByExample in JPA that will work within a generic DAO via reflection for any entity type? I know I can do it via my provider (Hibernate), but I don't want to break with neutrality...
Seems like the criteria API might be the way to go....but I am not sure how to handle the reflection p...
Hello Guys!
I have a Question class in ActiveRecord with following fields:
[ActiveRecord("`Question`")]
public class Question : ObcykaniDb<Question> {
private long id;
private IList<Question> relatedQuestions;
[PrimaryKey("`Id`")]
private long Id {
get { return this.id; }
set { this.id = value; }
}...
I have the following mappings of which Im trying to bring back 0 - 1 Media Id associated with a Product using a left join (I havnt included my attempt as it confuses the situation)
ICriteria productCriteria = Session.CreateCriteria(typeof(Product));
productCriteria
.CreateAlias("ProductCategories", "pc", JoinType.InnerJoin)
.Create...
Any one who tell me the query using criteria/hql/sql.
Requirement is that user enter email or username the query return the password of the
user from table user.
...
Hi!
I have a "super entity" SuperEntity and three entities ChildEntity1, ..., ChildEntity3 which extends the super class.
It's easy to search for all entities in the database, i.e. we could use
session.createCriteria(SuperEntity.class);
It's no problem to search for one specific entity type, too, just replace the SuperEntity with a...
i,
I have a parent child relationship, let's say class and children. Each child belongs to a class and has a grade. I need to select the children (or the ids of the children) with the lowest grade per class.
session.CreateCriteria(typeof(Classs))
.CreateAlias("Children", "children")
.SetProjection(Projections.ProjectionList()
.A...
I'm using Hibernate criteria and would like to add an order-by clause that is functionally the same as this SQL:
order by abs(dateSubmitted - 125234234)
Where dateSubmitted is a long and the number subtracted from it will be user-supplied (as a date). I'm trying to order records by their 'distance' from a user supplied date.
I've tri...
Hi everybody. I'm using NHibernate with Lambda Extensions. I'd like to know how to nest a Max function with a Substring.
The following statement retrieves Max("invoice_id")
var ret = session
.CreateCriteria<Invoice>()
.SetProjection(Projections.Max("invoice_id"))
.UniqueResult();
but in my case the field...
I am having trouble optimizing Hibernate queries to avoid performing joins or secondary selects.
When a Hibernate query is performed (criteria or hql), such as the following:
return getSession().createQuery(("from GiftCard as card where card.recipientNotificationRequested=1").list();
... and the where clause examines properties that ...
Hi,
I have one entity that contains a set of another entity.
Entity1 contains Set entityTwos
I want to create a search criteria for an "id" field inside entityTwos.
I searched, but didn't get any answers. Anybody have an idea?
Thanks,
Sri
...
Hello. I've got common NH mapping;
<class name="Order, SummaryOrder.Core" table='order'>
<id name="Id" unsaved-value="0" type="int">
<column name="id" not-null="true"/>
<generator class="native"/>
</id>
<many-to-one name="Client" class="SummaryOrderClient, SummaryOrder.Core" column="summary_order_...
Hi,
I'm trying to do a very simple sql query like this, to a propel Criteria :
SELECT count(id_user) FROM myTable WHERE id_page = 5
I did'nt found informations on the documentation.
Have you an idea ??
...
HI,
I try to translate this query :
SELECT *
FROM `reunion` , lieu
WHERE reunion.lieu_reunion = lieu.id_lieu
to propel query :
$c=new Criteria();
$c->addJoin(ReunionPeer::LIEU_REUNION,LieuPeer::ID_LIEU, Criteria::LEFT_JOIN);
$this->reunions = ReunionPeer::doSelect($c);
But in my template, when I made a print_r($reunions), the fie...
Dear All,
I am having troubles with a nHibernate query.
I have a db which stores vehicle info, and the user is able to search the db by make, model, type and production dates.
Make, model & type search is fine, works a treat, it is the productions dates I am having issues with. So here goes...
The dates are stored as ints (StartMonth...
Hi,
i have two entities named Parent and Child, linked in a one-to-many relationship. The Child entity has a boolean isStudent property.
How do i get, using the Hibernate Criteria API, all the Parent entities that have at least one Child with isStudent = true?
I was trying to use a Projection object to count all the parents that have...
I'm trying to pull back a list of items that have a specific type of item in a set.
For example:
<class name="Owner" table="OWNER">
<id name="id" column="OWNER_ID" />
<set name="cats" table="OWNER_CATS" lazy="false">
<key column="OWNER_ID" />
<many-to-many class="Cat" />
</set>
<class name="Cat" table="CAT" discriminator-v...