hi all,
i want to format date to string in hql select, for example i have purchasing data with transaction date in it:
class Purchase {
private Date datePurchase
}
and i want to select date in a certain format, for example yyyyMMdd, can i do that in hql?
actually i can iterate through all purchase data returned by query, and star...
ItemTag objects contain an Item object and a Tag object. (These are Java domain objects.)
This simple query works as expected. I get back a list ItemTags and can do all the wonderful things that ItemTags are supposed to do:
def theTags1 = ItemTag.findAll("from ItemTag b")
For example:
println(theTags1[0].tag.tag)
gives me this as...
I have figured out that I can use hibernate to get the sum of a number of entities using HQL as follows...
public Long getEnvelopeTotal(AbstractEnvelope envelope) {
String query = "select sum(t.amount) from User_Transaction t";
Long result = (Long) hibernateUtil.getSession().createQuery(query).uniqueResult();
return result;
...
hello
when I used sql query in hibernate (ie hql) I got following error:
student is not mapped. [select stud.vStudentName from student as stud]
here is table name in mysql and following is function of select query.
public static void querySubject(Session session)
{
String sql_query="select stud.vStudentName from student as ...
Hi there,
I have a class Order that contains a set of OrderSection's that itself contains a set of OrderItem's.
In SQL, one can use a SELECT statement in a JOIN clause as done in the following query:
SELECT
o.id,
o.amount,
sum(s.quantity*s.price),
sum(s.quantity*i.price)
FROM
orders AS o
JOIN ordersections AS s...
Hi every one I have these classe
@Entity
@Table(name = "login", uniqueConstraints={@UniqueConstraint(columnNames={"username_fk"})})
public class Login implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue
private int id;
@Column(name = "password", length = 64)
private String password;
@Column(na...
Is there any way to use expressions in the Select clause?
E.g.:
select u.Age/2
from User u
I'm having this exception right now:
NHibernate.QueryException: ',' expected in SELECT before:/ [select u.Age/2 from Business.Entities.User u]
...
I have Hibernate domain objects that looks like this:
class Player {
List<Item> inventory;
}
class Item {
List<Enchantment> enchantments;
}
class Enchantment {
boolean isSuperiorEnchantment;
}
I need to construct an HQL query that returns to me a list of all players that have at least one item wit...
In HQL, how can I use bitwise operators? I want the resulting SQL query to look something like
SELECT RoleId, RoleName, RolePerms WHERE (RolePerms & @Parameter) = @Parameter
However, writing this HQL
select from Role where (RolePerms & :param) = :param
gives me this error: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of...
I understand that a IQueryable cannot be serialized. That means that queries can not be serialized, sent to a webservice, deserialized, queried and then sent back.
I was wondering if it is possible to convert a hibernate linq query to hql to be sent over the wire.
Is there another route I am missing?
...
I'm trying to use HQL to find records where two date fields are within 1 month of each other.
Query query = session.createQuery("from com.ep.cqprojects.db.Projects "
+ "where active_date - kickoff_meeting_date < interval '1' month ");
Unfortunately the database used apparently doesn't understand interval.
How can I compare the in...
And if so, what is the syntax?
Assume that I want an instance of Foo to be unassociated from all instances of Bar:
In SQL it would simply be:
delete from FOO_BAR_MAPPING
where FOO_ID = ?
In HQL, I assumed it would be something like:
delete from Bar.foos foos
where foos.id = :id
(where foos is a mapped collection of Foo)
But appea...
I am trying to query against an IList<string> property on one of my domain classes using NHibernate. Here is a simple example to demonstrate:
public class Demo
{
public Demo()
{
this.Tags = new List<string>();
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IL...
Hi every one, I have this Table
CREATE TABLE IF NOT EXISTS `branch` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`studcount` int(11) DEFAULT NULL,
`username` varchar(64) NOT NULL,
`branch_fk` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `FKADAF25A2A445F1AF` (`branch_fk`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=14...
Hi,
I have 3 classes :
public class Transformation
{
private int Id;
private int Type;
private int Ind;
private IList<Action> Actions;
private IList<Condition> Conditions;
private Boolean IsEnabled;
}
public class Action
{
private int m_Id;
private Transformation m_Tr...
In Hibernate 3, is there a way to do the equivalent of the following MySql limit in HQL.
select * from a_table order by a_table_column desc limit 0, 20;
I don't want to use setMaxResults if possible. This definitely was possible in the older version of Hibernate/HQL, but seems to have disappeared.
...
Hi every one,
I have Login Table that have utf8 charset and utf8 collation when I want check user name and retrieve other information for this specific user name the hql query give me the same result with lowercase and uppercase.
what should l do for my HQL query that work case sesitive
I use Mysql 5 and java hibernarte
this is my que...
How to build valid HQL string, which is equivalent to
UPDATE table SET field = null WHERE ....
...
I've recently started using FluenNHibernate and some weird problem appeared when I tried to write unit test with SQLite.
I use SQLite in memory database for test, for each test method I am clearing data existing in database. In example:
var u = new User() { Name = "Piotr" };
_session.Save(u);
_session.Clear();
var list = _session.Creat...
Hi,
I am new at Hibernate, and I have a question regarding HQL Lejt join.
I try to left join 2 tables, patient and provider, and keep getting "Path expected for join! " erroron the second table. Appreciate it if anybody can help on this issue!
Here is the mapping of the 2 tables/classes:
patient.hbm.xmL:
<?xml version="1.0"?>
<!DOC...