I'm really confused about transaction propagation in Spring with Hibernate. I use Spring @Transactional annotations on my service layer methods. Some are marked as 'read-only=true'. If one of my read-only service methods calls a method that is not read-only, how can I deal with this?
I'm thinking I can mark all my read-write methods to ...
Another Hibernate question... :P
Using Hibernate's Annotations framework, I have a User entity. Each User can have a collection of friends: a Collection of other Users. However, I have not been able to figure out how to create a Many-to-Many association within the User class consisting of a list of Users (using a user-friends intermedia...
Hibernate: I want to have hibernate automatically generate my tables with names in lowercase.
For example, if my class is called com.myapp.domain.Customer, hibernate will generate a table named Customer. I want it to be called customer. I know I can use the @Table annotation to specify the table name per class. But I want it to happen "...
I'm trying to combine Spring with Hibernate using Annotations and I'm getting the following error:
org.springframework.orm.hibernate3.HibernateSystemException : Unknown entity: entities.Bar; nested exception is org.hibernate.MappingException: Unknown entity: entities.Bar
Here is my setup...
My Entity:
package entities;
@Entity
...
I'm trying to write an HQL query which will calculate an average rating for an item. I want the query to return 0 instead of null when there are no rating for a given item - so that I can use my query as a subquery. So is it possible? Is there an HQL equivalent of IFNULL or NVL?
...
Hi,
I am writing a web application that allows a user to get an employee's personal information and edit it (email, phone, name, etc). When I deploy the application on the server, if I try edit the employee, I can occasionally get an error saying "Hibernate session is already closed." My code for talking to the database via hibernate is...
Hi,
with native SQL I get the database time with a statement like:
SELECT CURRENT_TIMESTAMP
with JPQL I get the same result with:
SELECT CURRENT_TIMESTAMP
FROM Customer c
WHERE c.id=1
Is there a way to get rid of the last two lines?
thanks,
...
i have entity A that has foreign key to entity B, does entity B need to have foreign key back to entity A? if yes, how?
coz entity B, id already used for primary key
entity A --> id, entity_a_name, foreign_key_entity_B
entity B ---> id, entity_b_name
...
I have an entity A that has a foreign key of entity B:
entity A --> id, entity_a_name, foreign_key_entity_B
When I call
return session.createCriteria(EntityA.class).list();
I get the property of entityB inside entity A as well. How do I make it lazy load so it will not load enityB if not needed?
...
entity A --> id, entity_a_name, foreign_key_entity_B
entity B ---> id, entity_b_name
when i delete entity B record, it suppose to auto delete entity A that has foreign_key_entity_B ?
Error: ORA-02292: integrity constraint (schema.FKA630D2FB5F0F1180) violated - child record found
...
hi,
I have one field in my table and values for that field willbe generated by the sequence which i have given in hbm mapping. now my question is, if i provide value for these field which has mapped with sequence , what will happen?
1. will hibernate ignore the value provided by me and it invoke its sequence?
or
2. will it take the va...
Given the following hibernate query:
String sql = "select distinct changeset " +
"from Changeset changeset " +
"join fetch changeset.changeEntries as changeEntry " +
"join fetch changeEntry.repositoryEntity as repositoryEntity " +
"join fetch repositoryEntity.project as project " +
"join fetch changeset.author as cha...
I'm using the following HQL query to try and load a set of objects when I select a Student object based on the advice found at the following link.
http://www.javalobby.org/articles/hibernate-query-101/
from gradebook.model.Student student where student.studentId=1 left join fetch student.scores
I get the following error.
unexpected to...
I have a Voucher - POJO mapped to two tables. The first mapping assigns an entity name "voucherA" and maps the POJO to TableA. The second mapping uses "voucherB" as entity name and maps the POJO to TableB.
Now i have also a customer POJO mapped to TableC. This POJO references vouchers in a list.
<list name="vouchers" table="TableC_vouc...
In one of my projects, I have an application that manages several clients (or customer if you prefer). For each of them, I have a dedicated schema on a database.
However, the application handles only one client at a time, i.e. the user must switch from one client to another in the application (at runtime, no restart of the application) i...
Hi,
We have a DB table that is mapped into a hibernate entity. So far everything goes well...
However what we want is to only map enentitys that satisty a specific criteria, like ' distinct(fieldA,fieldB) '...
Is it possible to map with hibernate and hibernate annotations? How can we do it? With @Filter?
...
I have a fairly sophisticated security mechanism that I implemented using Apache Shiro (formerly JSecurity). In order to know the exact visibility rules for an object, I need to run some code (i.e. lookup user's roles, permissions, groups, etc). I'd like to run queries that tell me objects that the current user is authorized to see.
...
I have the following class setup for a Student in Hibernate.
Class student contains a set of Score objects. Each score object contains the score, student id, and a gradeEvent object.
A grade event object contains things such as date, description, etc.
I want to fetch a student and load all there associated score objects and the gradeEven...
Hi,
I'm currently working on a (rather large) pet project of mine , a Swing application that by it's very nature needs to be multi-threaded. Almost all user interactions might fetch data from some remote servers over the internet , since I neither control these servers nor the internet itself, long response times are thus inevitable. A ...
Have domain objects: Profile and ProfileProperty. ProfileProperty static belongsTo=Profile and profile static hasMany=[profileProperties:ProfileProperty]. Each Profile has dozen profileProperties. Need to bulk insert profiles with properties.
Idea was to have Profile#extraProps of type of java.util.Map, marked as static transient =['ext...