I am having a great deal of trouble getting named queries to work with nHibernate. My latest problem is getting the error message "could not execute query" with no additional information. Are there any complete examples I can download from somewhere because all the tutorials and documentation examples provide code snippits but only tell ...
I'm using a custom named query with NHibernate which I want to return a collection of Person objects. The Person object is not mapped with an NHibernate mapping which means I'm getting the following exception:
System.Collections.Generic.KeyNotFoundException:
The given key was not present in the
dictionary.
It's getting thrown w...
Hey guys!
Let's imagine something like this:
class MyTable extends Doctrine_Table
{
public function construct()
{
$q = Doctrine_Query::create()->from('MyTable t')
->orderBy('t.creationDate DESC')
->limit(5);
$this->addNamedQuery('top5', $q...
I am using Nhibernate 2.1.0 in my project.
I have the an Item class with property Path and the following named query:
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2'>
<sql-query name='updateUNC'>
<query-param name='oldUNC' type='String'/>
<query-param name='newUNC' type='String'/>
<![CDATA[
update Item s s...
Hi all,
I've got the following named query in Hibernate:
<sql-query name="CreateLogTable">
CREATE TABLE IF NOT EXISTS :tableName (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`url` VARCHAR (750) NOT NULL,
`query` VARCHAR (500),
`ipaddress` VARCHAR (39),
`datetime` DATETIME NOT NULL,
`hits` MEDIUMINT UNSIGN...
Hi there,
I am using Nhibernate with fluent.
Now I want to call some Stored procedure and use named Queries.
I created some xml:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping>
<sql-query name="CleanAppendicesHierarchies">
exec intf_CleanUpAppendixHierarchy
</sql-query>
</hibernate-mapping>
FluentConfiguratio...
Hi all,
I have the following mapping
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Domain.Core"
namespace="Domain.Core">
<class name="Industry" table="INDUSTRY">
<cache usage="read-write" region="IndustryCache" include="all"/>
<id name="Id" type="In...
Hi all, I'm trying to set a parameter in my query, for example:
select * from Cars where Cars.color NOT IN (:color_params)
And when I'm adding the parameter in my JavaClass is like:
...
query.setParameter("color_params", "RED,BLUE");
...
And this is not working, is only working with only one parameter.
I've tried with
"'RED','BL...
In my MSSQL server I have a SQL view called AllFavourite. In order to load the data into my DTO class I have the following in my hbm.xml file...
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Domain.Model.Entities" assembly="Domain.Model">
<import class="AllFavourite"/>...
Say I have a Customer - CustomerOrder one-to-many bi-directional relationship with the CustomerOrder holding the total value of each order.
If I had a query to find the total value of all orders for a particular customer :
select SUM(o.orderValue) from CustomerOrder o where o.customer = :customer
Does it matter in which entity class ...
Hello,
I'm trying to put my named queries in my orm.xml (put in META-INF with persistence.xml) but my orm.xml seems to be ignored by hibernate/jpa.
When I try to create my named query with em.createNamedQuery("myQuery"), it returns that it can't find this query.
I use annotation and I would like to externalize my named queries in orm...
Is there any way to specify optional parameters (such as when search parameters are provided from a form and not all parameters are required) in a named query when using Hibernate? I'm using a native SQL query, but the question is probably applicable to named HQL queries as well.
I'm pretty sure the answer to this is 'no', but I haven'...
I am needing to create a named-query, and use it with one of the maps, that i currently have defined as a fluent map.
is it possible to continue using the fluent map, and be able to create the named-query dynamically in code? or, is switching to a hbm map the only option?
...
when trying to use the Enumerable method on a named query, with a Stateless session, as shown in the example at:
http://www.nhforge.org/doc/nh/en/#batch-statelesssession
i am seeing a NotSupportedException. the stack trace is as below:
System.NotSupportedException: Specified method is not supported.
at NHibernate.Impl.StatelessSession...
I do not use HibernateTemplate, but work with getCurrentSession() in my DAO.
I would like to know how to declare Hibernate named queries in a beans.xml file (I do not use hbm.xml).
And maybe Spring has alternative means to declare Hibernate named queries?
...
I have a one-to-one relation where I use CascadeType.PERSIST. This has over time build up a huge amount of child records that has not been deleted, to such an extend that it is reflected in the performance.
Now I wish to add some code that cleans up the database removing all the child records that are not referenced by a parent. At the m...
I wrote a named query in the entity class Voter
NamedQuery(name = "Voter.findvoter", query = "SELECT count(*) FROM Voter v WHERE v.voterID = :voterID" and where v.password= : password),
I want to call this named query and I also need to set voterID and password.
Can you help me. Thank you
...
Hi,
Other than default schema, for some SQL queries I need to access a particular schema. The issue is that the name of that particular schema is different for different environments.
After goggling I found that using this link I am able to specify the schema name in variable. If that’s true that I have following questions:
Will that...
I would like to load all objects that have a textual tag set to any of a small but arbitrary number of values from our database. The logical way to go about this in SQL would be to build an "IN" clause. JPQL allows for IN, but it seems to require me to specify every single parameter to IN directly (as in, "in (:in1, :in2, :in3)").
Is th...
I have a dozen or so named queries in my NHibernate project and I want to execute them against a test database in unit tests to make sure the syntax still matches the changing domain/database model. Currently I have a unit test for each named query where I get and execute the query, for example:
IQuery query = session.GetNamedQuery("Ge...