I am trying to assemble a query using hibernate criteria.
In my db, there is a [Game] table, a [Tag] table, and a many-to-many relationship modelled using a join table called [GameTag], which contains a game_id field and a tag_id field.
My input is a list of tags (or tag_ids), and I would like to retrieve all games having all of these ...
Hi there!
I have an entity, say
@Entity
public class Category {
private String name;
private int usersInCategory;
}
I want to fill usersInCategory field with some aggregating SQL query (select count(*) ... group by ...).
How can I do this in Hibernate?
...
How can I extract variables total, min, max from hibernate SQL queries and assign them to java variables?
(select count(*) as total, min(price) as min, max(price) as max from product).addScalar("total", Hibernate.INTEGER).addScalar("min", Hibernate.INTEGER).addScalar("max", Hibernate.INTEGER);
...
Hi,
I work on manage.py command which creates about 200 threads to check remote hosts. My database setup allows me to use 120 connections, so I need to use some kind of pooling. I've tried using separated thread, like this
class Pool(Thread):
def __init__(self):
Thread.__init__(self)
self.semaphore = threadin...
We're to use DTO's to send data to and from the presentation layer.
I have a method on a service object called PostAd which posts an advertisement entered by a user. The Ad has an association to another object called AdValues, which contain values for the Ad (title, price, description etc)
@Entity
public class Ad {
@OneToMany
Se...
Hi,
I'd like to view each Project by Client, but unsure how to use Datamapper to get this information out. I have my relationships setup like this:
class Client
property :id, Serial
property :name, String
has n, :projects, :foreign_key => "company_id"
end
class Project
include DataMapper::Resource
property :id, Serial...
The quote below has convinced to finally go ORM. In the past I havn't really liked ORM and wrote it off as a stupid way of doing sql. Dealing with hierarchical data in sql is a pain I don't want to deal with.
There's a reason we have these “Object-Relational Mapper” things, and it's because of a problem known as the Object-Relational...
I have an application in which I am trying to implement ManyToMany relation between 2 entities using Hibernate as my JPA provider.
The example I am trying is an uni-directional one, wherein a Camera can have multiple Lenses and Lense can fit into multiple Cameras.
Following is my entity class...(Just pasting the relevant part of it)
C...
I have two entity classes A and B which looks as follows.
public class A{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(mappedBy = "a", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
private List<B> blist = new ArrayList<B>();
//Other class members;
}
Class B:
pu...
Hi, Ruby on Rails ORM(object relational mapping) has a thing call polymorphic associations that allow a foreign key to be used to reference 2 or more other tables. This is achieved by creating an additional column called "type" that specifies the table with which the foreign key is associated with.
Does this implementation have a name f...
How would you do the following using the JPA query language?
select * from person where email in
(select email from person group by email having count(email)>1)
...
The Hibernate EntityManager documentation states, that:
You may use a combination of all three together, annotations without JPA
programming interfaces and lifecycle, or even pure native Hibernate Core,
depending on the business and technical needs of your project. You can at
all times fall back to Hibernate native APIs, ...
I'm building a Java Web Application using Java EE 6 and JSF-2.0, using the persistence API for all database operations.
The back-end is MySQL, but I have used the EntityManager functions and Named Queries in EJB-QL for all operations. Are SQL injection attacks possible in this case?
...
Hello,
I'm having a problem modelling the following problem in JPA. I have a JPA Entity class 'User', like so:
(accessors/mutators/extraneous fields/extraneous JPA configuration omitted for brevity)
@Entity
class User {
@Id
@Generated Value
long id;
@OneToMany
Report contributorReports; ...
I'm a first-timer to this and would like to have some guidance regarding how to store objects in a database..
I have an object Person, with a couple of fields in it. I have one PersonContainer which loads all the objects from the database.
What is best of these two: (or if they both suck, tell me what's the right thing to do)
Store th...
I started to think about tracking changes in complex object graph in disconnected application. I have already found several solutions but I would like to know if there is any best practice or what solution do you use and why? I passed same question to MSDN forum but I received only single answer. I would like to have more answers to lear...
I have two databases in MSSQL ,and i want to connect to them using JPA2 I have managed to get it working with one . Can some one help me how do i do that?
Thanks a Lot.
...
Hi,
I am new to JPA.So my question would sould so simple to some. :)
Below is the Simple Query in SQL which i would like to convert to JPA.I already have the an Entity Class as TimeEnt
SELECT SUM (TimeEntryActualHours) As UnBilledHrs,SUM (TimeEntryAmount) As UnbilledAmount
From TimeEnt Where MatterID = 200;
Thanks a lot for you hel...
Hi,
I'd like to return the customers from Magento who where created the day before OR who where updated the day before. I tried to play with addFieldToFilter, without any success.
I also tried to manipulate Zend_Db_Select, no success.
So now I'm stuck!
Here are some of my tries :
$customer = Mage::getModel('customer/customer');
$cust...
I created the JPA 2.0 entity classes for our whole database (~200 tables), and now each time I rebuild my application and start it for the first time I get these messages:
INFO: <entity_classname> actually got transformed
INFO: <entity_otherclassname> actually got transformed
...
And the output of these (info) messages in Glassfish is...