when i do query SUBSTR(e.updatetime - s.updatetime, 1,30) i will get result below
+000000001 05:06:47.388000
can this save in java.util.Date? or which java class should i use other than String to ease me retrieve day,minutes,hours...
p/s: e.updatetime is timestamp type
...
My team at work maintains a fairly large webapp written on top of Spring and Hibernate. We're about to start making some fairly large scale changes to the site, and we're enamored with the rapid application development speeds allowed by some other frameworks, like Rails. We haven't really changed our stack much in the last year or two,...
usertable
----
id, username
grouptable
----
id, groupname
group_user
--------
uid, gid
books
----
id, groupname
Input parameters: groupname, username
output: list of books
Is it possible to use 1 sql statement to get list of books when username is inside groupname
Question 2: any good book to recommand to master complex sql st...
this is example of how sql is showed when using show_sql=true
Hibernate:
select
propertyse0_.entity_name as entity1_3_0_,
propertyse0_.entity_id as entity2_3_0_,
propertyse0_.entity_key as entity3_3_0_,
propertyse0_.key_type as key4_3_0_,
propertyse0_.boolean_val as boolean5_3_0_,
prop...
The naive attempt query would look like this:
Query query = em.createQuery("from org.domain.Resource r where r._parent = ? order by ?");
This does not work as the parameters should be data and not column names or syntax like ASC or DESC.
What kind of workarounds you have figured out for this dynamic ordering? Concatenating the orderi...
I receive a task for a project which uses Spring, Hibernate and Wicket.
In a particular HTML page I must have the possibility to create a filter(set the name of the filter and its parameters). I must create a list of filters in this way.
In the same time, I must have the possibility to edit and delete the filter, and of course, to use t...
Suppose I have the following objects (one table per object) with this relations:
A -> B -> C -> D
If I findById an instance of A, all B, C and D are returned which is not I want. Is this possible to force Hibernate only to return A (or only it's primitive properties)?
I know that I can write "SELECT a.x, a.y, a.z, ... FROM A" and then ...
Hi
I'm a .net dev, usually do this using nhibernate and can work with that fine. I'm doing a project which needs to be written in Java and have the following issue:
All I have so far is a blank java project setup in eclipse. I have C:\work\lib\java\cp\hibernate3.jar in the Referenced Libraries node in the package explorer.
in my code ...
For some reason I can never figure out how to do things via criteria api.
I have a HQL:
from Track track where size(track.trackTitles) > 1
Is it possible to convert it into a criteria query on Track class? If yes, how: what Restriction should I use?
...
As of now I have a working Spring application with persistence. However now I want to use Hibernate with JPA to do all of my database activities. I want to do this using an entitymanager.
I've been reading many documents and tutorials on this matter, I've been getting confused on whether I need a persistence.xml file or not. Also I've ...
I have 2 domain objects with a one-to-many relationship. Just as an example:
Class Author{
static hasMany = [posts: Post]
}
Class Post{
Author author
}
In the database the post table has a field called author_id. In my application, I have a bunch of author ids that I want to associate with posts. I can do this by first querying th...
I'm still struggling with changing my Spring Application to use Hibernate with JPA to do database activities. Well apparently from a previous post I need an persistence.xml file. However do I need to make changes to my current DAO class?
public class JdbcProductDao extends Dao implements ProductDao {
/** Logger for this class and s...
Hello
I am trying to make a query with Hibernate criteria API. It looks simple but I can't get it to work.
I have 2 tables. Person and Roles. Person has a set of roles. Role doesn't have any reference to Person. (i.e a guy A can be admin, user, another girl B can be only admin, etc...)
I just want to to search for everyone who is doing ...
I have these entities
class Foo{
Set<Bar> bars;
}
class Bar{
Foo parent;
String localIdentifier;
}
With this mapping (sorry, no annotations, I'm old fasioned):
<class name="Foo">
...
<set name="bars" cascade="all-delete-orphan" lazy="false" inverse="true">
<key>...</key>
<one-to-many class="Bar"/>...
I need to synchronize two databases.
Those databases stores same semantic objects but physically different across two databases.
I plan to use a DTO Pattern to uniformize object representation :
DB ----> DTO ----> MAPPING (Getters / Setters) ----> DTO ----> DB
I think it's a better idea than physically synchronize using SQL Query on e...
I try to write an big test class.
I'm using Junit, Hibernate and TopLink and H2 database. Before this I used EJB3Unit (including Hibernate and H2).
My test class has 57 test methods. If I run all test at once randomized one or more test fails. If I run each test alone, I get no error.
Has anyone an idea what's going wrong? And how I c...
Hi, all
I'm a newbie to Hibernate, so please bear with me if this is obvious or something.
I have an Item POJO which contains a Set<String> consisting of labels. The labels are contained on another Database table from the Item table, so I do a join to populate the pojo.
I'm trying to run a simple example query from the book "Java Pers...
I'm currently working on a batch import feature that sits on top of Hibernate and MySQL. My goal is to have Upsert functionality for several tables. I'm finding myself writing a lot of code to deal with seeing if the row exists by key and branching to right method. I was wondering if there might be a better way, i.e. something analogous ...
I'm having some trouble representing an object hierarchy in Hibernate. I've searched around, and haven't managed to find any examples doing this or similar - you have my apologies if this is a common question.
I have two types which I'd like to persist using Hibernate: Groups and Items.
* Groups are identified uniquely by a combination...
Hi Guys,
I'm trying to get a report using Criteria and ProjectionList, and I'm pretty new using this through hibernate.
So I have this model:
private Long _userId;
private Category _category;
private Long _companyId;
private Double _amount;
private Date _date;
And I building the query using this:
public List sumPaymentsByU...