hibernate

Mapping A Property Via A Hibernate Named Query

In my database structure, I have tables T_DEPARTMENT and T_EQUIPMENT_STATS (stats having a many to one relationship with department via departmentid foreign key). However, departments report their equipment monthly (available, in use, broken, etc). In the Department class, I want a Map (actually a ConcurrentHashMap because of threading...

count(*) in hibernate criteria ?

I have a combination of search criteria which implemented by using hibernate criteria. And I added a pagination like this : criteria.setFirstResult(offset).setMaxResults(pageSize).setFetchSize(pageSize).list(); This is not enough for a pagination , so I have count the total result size . totalResult = (Integer)criteria.setProjection...

CF9 EntityDelete: How to delete entities

If I have an array of entities, whats the easiest way of deleting the entire array of entities (or to put it this way, the entire ORM table)? I have: <cfset allUsers = EntityLoad("User", {}, false)/> Now to delete all the entities, would I use some sort of a loop? If so, how do I access individual entity primary keys within? I tried: ...

Enum in Hibernate, persisting as an enum

In my MySQL database, there's the column "gender enum('male','female')" I've created my enum "com.mydomain.myapp.enums.Gender", and in my Person entity I'm defined "Gender gender". Now I'd want to keep the enum type in my MySQL database, but when I launch my application I get: Wrong column type in MyApp.Person for column Gender. F...

Why delete-orphan needs "cascade all" to run in JPA/Hibernate ?

Hello, I try to map a one-to-many relation with cascade "remove" (jpa) and "delete-orphan", because I don't want children to be saved or persist when the parent is saved or persist (security reasons due to client to server (GWT, Gilead)) But this configuration doesn't work. When I try with cascade "all", it runs. Why the delete-orphan ...

Security question: how to secure Hibernate collections coming back from client to server ?

Hello, I've got a simple pojo named "Parent" which contains a collection of object "Child". In hibernate/jpa, it's simply a one-to-many association, children do not know their parent: these Child objects can have different type of Parent so it easier to not know the parent (think of Child which represents Tags and parents can be differ...

complex combine sql

query 1 : this will count all the record with email '[email protected]' select count(*) as total from userbase join extrauserinfofromhrms on userbase.username = extrauserinfofromhrms.useremail right join logevent on userbase.username = logevent.useremail join eachworkflow on logevent.workflowid= eachworkflow.workflowid where logevent.actio...

Get children count via HQL

Hi, I have a one-to-many mapping between a parent entity and child entities. Now I need to find the number of children associated with each parent for a list of parents. I am trying to do this with HQL but I am not sure how I can get the list of parents in there. Also, I don't know how I can return the entity itself and not just its ID....

Bidirectional association in indexed collection

The Hibernate reference document says: A bidirectional association where one end is represented as a or , requires special consideration. If there is a property of the child class that maps to the index column you can use inverse="true" on the collection mapping Then in example map-key is linked with child table on "name" column. ...

load attribute of other class in hibernate

hi, These are my classes. public Class ClassA { int a; ClassB b; public int getA(){return a;} public ClassB getB(){return b;} } public Class ClassP { int p; int q; int r; public int getP(){return p;} public int getQ(){return q;} public int getR(){return r;} } these are my class. previously i was loading above using many-to-one m...

Hibernate criteria question.

I have following POJO`s: - Company Node (nodeID, company) User (userID, node) I want to create where clause(via Criteria) which will return to me every user for given company. Something like ... Criteria criteria = session.createCriteria(User.class) criteria.add(Restrinctions.eq("node.company", someCompanyObject); But this is not ...

Struts2 Context handling..

Hello Friends! I need some help in session management for database in hibernate. Working with struts2 and hibernate. I have gone through simple apps. Now I want my Database connection in Startup so that I don't need to make connection overhead everytime I request. In short How to configure my hibernate session in ServletContextListener. ...

checks for constraint violation before persisting an entity

What is the best mechanism for preventing constraint violation checks before creation | modification of an entity? Suppose if the 'User' entity has 'loginid' as the unique constraint, would it be wise to check if there is an user entry already with this loginid name before creation or modification. OR Would you let the database throw...

Grails + Google Maps API

Hello, guys. I`m trying to dynamically represent the changes of coordinates of a groovy domain object via Google Maps API. The object has fields: Double lat Double lng and a method: void flyTo(lat, lng){ Thread.start(){ while (locked){ changeCoords (this) this.save() } } and here is a JS to repopulate changes to ...

An application with Flex, BlazeDS, Apache Tomcat, Java and Hibernate

I want to make an application which involves technologies like Flex, Java, Hibernate, BlazeDS and the server is Apache Tomact 6.0. Can anybody help me in how to link the various files I have. I'm using Eclipse Europa currently. I want to know where to deploy the .mxml and .class files and where BlazeDS will come into all this. ...

Can the usual ORM solutions interact with OO databases?

For example, can Hibernate handle CouchDb? What about support for other OO databases in other ORM solutions? One of the (not that important) benefits of an ORM solution is the possible ability to swap one database vendor for another. What if you swap a relational database for an object oriented one? [edit] if you feel like giving the ...

JSF + Spring + JPA + Hibernate: keep entitymanager alive when rendering view?

Totally new to Spring & Java development but working on a project for a class with some experienced developers. I believe we're using Spring MVC as our web layer(but I'm a C# guy so I may be mistaken in that regard). We have a view that gets an object with lazily loaded properties -- pretty straightforward stuff. Yet when I call one o...

Eclipse plugins for Spring / Hibernate development?

I have a running dynamic web project in Eclipse (Java EE + Maven + Spring). I am at the point where I need to integrate a persistence layer and want to use Hibernate with a mySql database. I am wonder what plugins would be useful for me at this point? For Hibernate should I install hibernate tools or is it not necessary? Are then any ...

JPA Secondary Table Issue

I have a three tables: User, Course, and Test. Course has a User foreign key and Test has a Course foreign key. I am having trouble mapping the Test collection for each User since I need an intermediary step from User -> Course -> Test. I am trying to use a SecondaryTable since the User key for the Test is its associated Course row. A...

Spring-Hibernate DAO naming convention?

Is it typical to name DAOs in the following way: UserDAO - interface UserDAOImpl - implements UserDAO I am wondering if its standard to use the suffix 'Impl' for the implementation or if something more meaningful is the best practice. Thanks. ...