hibernate

Groovy criteria query

Hi, I have a domain model that looks like this Category 1 ------- * Type 1 ------- * Expense Or in English "An expense has a type, and each type belongs to a category". I want to write a Criteria query that will find all expenses in a particular category. I tried both this Expense.withCriteria { eq('type.category', someCategoryI...

changes are not being reflected in when getting the result after insert thru hibernate

Hi, I am using hibernate and spring mvc, when i insert a record in DB, and try to access that that right after that, then i don't get the result. e.g. if insert a record for newly reg. user and login in him right after registering it then result set is empty. I am using hibernate templates. what could be the problem and what i am m...

Error handling String to Integer and inserting empty values in database

I am new to Java and I am creating an application in JSF and Hibernate. I have a form which has several input fields but only one field that will be an Integer, Age. The rest of them will be Strings. Age is not a required field so the user can enter it or not but my application should insert null or an empty string into the DB if the f...

Hibernate LazyInitializationException: failed to lazily initialize a collection of role

I have a web service which is essentially a wrapper for a DAO. I am calling the web service/DAO to request a collection of entities. The "parent" entity class contains a collection of "child" entity objects, i.e. a one-to-many relationship. The DAO method call which fetches the "parent" entity collection (i.e. myDAO.findAll()) retur...

JPA target entity type based on column value

Hello, I'm trying to move some old code from hand-made persistence to Hibernate. The issue here is a peculiar mapping where the target entity type/table is defined by a column value. Example database table: Table "Relation": id - my primary key parentType - a char that specifies the type of parent (e.g. 'I' meaning an object in the ...

How Would One Find a Dependency-Order list of Tables to Delete for Test Data?

I have a test suite that needs to delete any existing data in my local MySQL test instance for a large number (but not all) of the tables in the system. delete from customer; Of course, customer has quite a few foreign keys to it, so I also have to delete a few more tables... delete from customer_email; delete from customer_phone;...

Hibernate Envers for Doctrine?

Doctrine 1.x and 2 both offer some kind of Versionable support in the form of a separate auditing table that tracks changes over time. However, the versions appear to be intended for per-row use (ie, they all maintain their own version number) instead of database-wide, such as in Hibernate Envers, which gives every row a unique revision ...

Null list returned from hibernate query with embedded id

I have an entity with an embedded key. The entity has only the key as a field and the key has 7 fields, some of which can be null. When I run the following query: Criteria criteria = session.createCriteria(getPersistentClass()); criteria.add(Restrictions.eq("id.profPropertyId", profileExtensionName)); Object obj = criteria.list(); log...

JPA: default column name mapping for @ManyToOne relations

When we have a class: @Entity Order implements Serializable { @Id private Integer id; ... } and: @Entity OrderLine implements Serializable { @Id private Integer id; @ManyToOne Order order; ... } What row name will the property order map to? order_id, ORDER_ID or Order_id? (ommiting the @JoinColumn...

Hibernate and Internationalization using Tables

Hi With regards to the answer on my previous post: http://stackoverflow.com/questions/3958529/internationalization-of-user-data/3958595#3958595 Would it be possible to use Hibernate to link these tables together using annotations (or something else?) so that the existing models and database queries do not have to change? J ...

a really basic implementation for hibernate calls plsql function

hi, i really need a basic hibernate implementation calls oracle plsql function. it must include configurations, dao and test class. is there any example for that? ...

How to wrap an object change in my own transaction and incorporate it with Hibernate to JTA?

I have a web-app, which I deploy on Tomcat 6 and it uses Hibernate. It receives messages on a JMS queue which trigger changes both to my DB, via Hibernate and to an Object of mine (Agent). The web-requests also access the DB, via Hibernate, and access the shared object (there's a ConcurrentHashMap<AgentId,Agent> held by a singleton). My ...

Any example on GWT 2.1 RequestFactory with Hibernate?

I try to download expenses sample project but can't make it run. I'm not familiar with maven and don't want to be confused by other new features (like mobile, activity & place...etc). I'm not using data nucleus nor appengine. Just want to have a bare bone RequestFactory with hibernate so that maybe I refer to it and migrate my code fro...

Hibernate query:Don't delete child when removing association with parent.

I am removing a Child from its association(many to one) to Parent.When i use saveOrUpdate method on Parent, Hibernate by default tries to remove Child from the Table.Is it a bug with hibernate?? How can I avoid this condition??? ...

Problem with Hibernate Annotations - id is not set correctly

Hi, I have a whole bunch of Java beans annotated like this with JPA: import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @Entity public class TitleEntry extends Entry { private Long id; public TitleEntry() {} public TitleEntry(St...

Different results fetching results with query api vs. hql

I have the following entity (not exact but gives a general idea): @Entity public class WebElement implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue private Long id; @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL }) private Set<CoreElement> coreElements; ...

Hibernate - Connection not closed in connection pool

I am using org.apache.commons.dbcp.BasicDataSource and I want to monitor the UNCLOSED connections. What properties i have to set in hibernate config file? Thanks. Giovanni ...

Hibernate criteria

Hello, I have table "Event" and table "Sessions" and each event has a set of sessions and each session has start date and end date. Event start date : is the start date of first session of that event Event end Date : is the end date of the last session of that event. what i want to do is return all the events that have start date wi...

How can I do paging with @OneToMany collections

Suppose I have a Post entity and a Comment entity and a one to many relationship: @Entity class Post { ... @OneToMany List<Comment> comments; ... } How can I achieve paging like this: Post post = //Find the post. return post.getComments().fetch(100, 10); // Find the 11th page (page size 10); Is it possible to emulat...

How to read SQL Server 2008 date into Java using JPA

I need to use java.util.Calendar in order for Axis2 webservice client to send/receive Date objects. So in my JPA model object I changed all java.sql.Date into java.util.Calendar. By using java.util.Calendar the Axis2 webservice part work ok. I'm able to save a java.util.Calendar object into database. Problem is that I can not read th...