Hi all,
I'm struggling with a Grails service.
The service gets AJAX calls from the clients and behaves like a simple local cache for remote objects:
void **someCallFromClient**() {
// extract params
def results = remoteService.queryService(params)
results.each{
// try to fetch result object from local DB
def obj = Some...
I am using Hibernate in my project and there is a certain scenario where I want to use the uniqueResult() method on the org.hibernate.SQLQuery class to perform native SQL INSERT and UPDATE operations.
I did try using the executeUpdate() method on the same class. But I get an error saying that they are used for HQL updates only.
Please ...
I have this DB design:
CREATE TABLE report (
ID MEDIUMINT PRIMARY KEY NOT NULL AUTO_INCREMENT,
user MEDIUMINT NOT NULL,
created TIMESTAMP NOT NULL,
state INT NOT NULL,
FOREIGN KEY (user) REFERENCES user(ID) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE reportProperties (
ID ...
Is there a way to convert table entries from an old table to a new one using the same entity class?
To be specfic, here are my entity class' annotations for the new table:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "benutzer_id")
private Integer benutzerId;
@Basic(optional = false)
@...
I'm still a little new to hql, and I had a question about aggregation functions and efficiency for a query I'm writing.
Let's say I have this class mapped in hibernate (getters/setters/constructors/etc. omitted for brevity):
public class Foo
{
private int i;
private String s;
private float f;
}
I want to do a hql query ...
Hi
I have two classes which have a Unidirectional One to Many relation with each other.
public class Offer{
...
@OneToMany(cascade=CascadeType.ALL)
@JoinTable(name = "Offer_Fields",
joinColumns =
@JoinColumn(name = "OFFER_ID"),
inverseJoinColumns =
@JoinColumn(name = "FIELDMAPPER_ID"))
private Set<FieldM...
Using hibernate with annotations, i want a one-many relationship to be sorted by the 'created' field on the 'many' table.
So far i've got this, which always ends up in a random order:
// The notes
@OneToMany
@JoinColumn(name="task_id")
Set<TaskNote> notes;
public Set<TaskNote> getNotes() {return notes;}
public void setNotes(Set<TaskNo...
I have a table with a name and a name_count. So when I insert a new record, I first check what the maximum name_count is for that name. I then insert the record with that maximum + 1. Works great... except with mysql 5.1 and hibernate 3.5, by default the reads don't respect transaction boundaries. 2 of these inserts for the same nam...
I am looking to start work on a brand-new project, something I've been thinking about for a while as my first independent sellable project.
It's broadly speaking a web-based service application, and my first choice, server-language is quite easy... I know Java pretty well from working on Java web-apps in the past.
However my experience ...
Hi All,
Can I use newest version of hibernate 3.5 (3.5.0-3.5.2) as JPA1 provider with EJB3.0 on Glassfishv2?
I tried, but hibernate 3.5 required JPA2 spec and obviously this did not work with GFv2.
Thanks,
Anton
...
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.
...
I have a column in my DB that is set with Identity(1,1) and I can't get hibernate annotations to work for it. I get errors when I try to create a new record.
In my entity I have the following.
@Entity
@Table(schema="dbo", name="MemberSelectedOptions")
public class MemberSelectedOption extends BampiEntity implements Serializable {
...
Is it possible to perform date arithmetic using JPA/Hibernate? For example, I have an entity with a java.util.Date field indicating when the row was created. Is it possible to perform a query using JPQL and include date arithmetic on that field? For example, can I perform a COUNT(*) of rows and then GROUP BY the month in that field? ...
In the beginning there is a problem that wants to be solved. In my case i got an LazyInitializationException while using indexof in a Collection to retrieve an Object for manipulation. Here i start to think about using equals in EntityBeans (OR-Mapper at all). I know there are some discussions about overriding equals in association with ...
Hi.
I'm trying to find something to help me with y problem.
Now I'm changing the strategy.
What I need is to build (because I think there is nothing like this) a tool that take a query, a multi-table select, and translate all this in many single table queries.
Does anybody has any idea about how hibernate does that (based on the dialect...
I need some help defining the following object hierarchy/ database relationship in Hibernate
From the object sense – Agent is inherited from Person and Agency is inherited from Organization. they are inherited from Party which can have multiple Addresses associated with it
The database consists of
Agent
-ID
-Name
-PartyID (referenc...
Is it OK to truncate tables while at the same time using Hibernate to insert data?
We parse a big XML file with many relationships into Hibernate POJO's and persist to the DB.
We are now planning on purging existing data at certain points in time by truncating the tables. Is this OK?
It seems to work fine. We don't use Hibernate's s...
Can anybody suggest simple CMS to manage existed project on JAVA (Spring+Hibernate). I need simple CRUD operations for Hibernate Mapping objects (annotations based mapping).
...
Hi all, im developing a java swing app and i would use hibernate for persistance.
Im totally new in jpa, hibernate and ORM in general.
Im follow this tutorial, its easy but the problem is the java class that descrive a table in db are made from the table with reverse enginering.
I want do the opposite process: i want make db table from...
This is an extremely common situation, so I'm expecting a good solution. Basically we need to update counters in our tables. As an example a web page visit:
Web_Page
--------
Id
Url
Visit_Count
So in hibernate, we might have this code:
webPage.setVisitCount(webPage.getVisitCount()+1);
The problem there is reads in mysql by defaul...