Spring 3.0.2,
Hibernate 3.5.0,
Hibernate-Validator 4.0.2.GA
I am trying to inject Spring dependencies into a ConstraintValidator using:
@PersistenceContext
private EntityManager entityManager;
I have configured the application context with:
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFacto...
Consider the following association
Book has OneToMany Chapters
If i execute:
session.save(book)
session.save(chapter)
session.getTransaction().commit()
Hibernate generates insert query for Book and insert query for Chapter
But if i execute:
session.save(chapter)
session.save(book)
session.getTransaction().commit()
Hibernate execu...
My simple query looks like this on JPQL:
SELECT COUNT(r) FROM org.domain.Resource r WHERE r._parent = :parent AND r._metadata[:metadataKey] is not null
But Hibernate SQL output looks like this (both for H2 and MySQL):
select
count(resource0_.id) as col_0_0_
from
resources resource0_,
resou...
I am trying to map a normalized Java model to a legacy database schema using Hibernate 3.5. One particular table encodes a foreign keys in a one-to-many relationship as a bit array column.
Consider tables person and club that describes people's affiliations to clubs:
person: .----.------. club: .----.---------.----------------------...
Hibernate criteria, using DB2 dialect, generates the following sql with
composite keys in the IN clause, but DB2 answers that the query is incorrect:
select * from tableA where (x, y) IN ( ( 'x1', y1) )
but, DB2 throws this:
SQL0104N An unexpected token "," was found following ", y) in
( ('x1'".
Expected tokens may include: "+". S...
Hi,
I'm testing the CRUD operations of my DAOs in JUnit tests.
When i execute the single test, Hibernate always resets the schema and populates the DB in a known state. But when i execute multiple tests in a row, Hibernate resets the schema once, and then the data is accumulated during the execution of the tests.
This is an unexpected...
I know Hibernate calls setters when you lookup a bean.
But I recently noticed the setter was being called by Hibernate when we we were not doing any lookups. We had created our POJO's and then called save. Why would Hibernate call setters in this case?
Update: The setter call seems to be happening when we are actually calling delet...
This is a real beginner Hibernate problem. I have a problem with the mappings for two tables. The first table is MARKET, and the second is MARKET_MENU_BRANCH which contains a list of rows for each MARKET row. When I save a new Market, I want it to insert both MARKET and MARKET_MENU_BRANCH rows, but in fact it seems to insert MARKET an...
I'm trying to map a many-to-one relationship from MarketMenuBranch to Market. My classes look like:
public class Market implements Serializable {
private int id;
private String name;
private List<MarketMenuBranch> marketMenuBranches;
// accessors / mutators etc...
public class MarketMenuBranch implements Serializable {...
I have table like below
id, employee_no, survey_no, name
1 test 1 test_name
2 test2 1 test_name2
3 test3 1 test_name3
4 test4 2 test_name4
how to query with Restriction.in by combining below AND into one IN statement?
IN[ (if(survey_no==1) && employee_no...
I have the following tables:
Student
Student_Course
Course
Now when I create a student I only want to create a user and add a row to student_course.
The "problem" I have is that when I set the set of courses in Student to cascade="save-update" that an update is also invoked on course. I was wondering if there was a way to prevent thi...
I have the following database schema :
Two tables, books and tags, with n-m relationship.
Books - Tags
We can have for example the book 1, with tags {A,B,C}, and book 2, with tags {A}.
I would like to select the books according to a list of tags.
For example : selected tags list : {A,B}
-> book 1
My idea was to use the MINUS SQL fu...
How do you handle object equality for java objects managed by hibernate? In the 'hibernate in action' book they say that one should favor business keys over surrogate keys.
Most of the time, i do not have a business key. Think of addresses mapped to a person. The addresses are keeped in a Set and displayed in a Wicket RefreshingView (wit...
Hi I am using Hibernate 3.0
Facing some issue with data saving.
in below code client is pojo that i want to save. Even though i tried to flush still same problem
try {
getHibernateTemplate().saveOrUpdate(client);
System.out.println("This is executed");
getHibernateTemplate().getSessionFactory().get...
I am wondering where the hibernate second level cache works as expected if I put a where clause in the hbm.xml class definition:
<hibernate-mapping>
<class name="com.clazzes.A" table="TABLE_A"
mutable="false" where="xyz=5" >
<cache usage="read-only"/>
<id name="id" />
...
Will hibernate still put the id as key into the ca...
given parent entity
@Entity
public class Expenditure implements Serializable {
...
@OneToMany(mappedBy = "expenditure", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy()
private List<ExpenditurePeriod> periods = new ArrayList<ExpenditurePeriod>();
@Version
private Integer version = 0;
...
}
and child one...
Hello all,
I'm in the exact same situation as this old question:
http://stackoverflow.com/questions/2077558/warn-could-not-register-destruction-callback
In short: I see a warning saying that a destruction callback could not be registered for some beans.
My question is: since the beans whose destruction callback cannot be registered a...
I'm trying to configure an ejb3 sample application, it's entities where mapped to postgres now I want the app run on Jboss4.3 and Informix using JPA.
If the DDL creation <property name="hibernate.hbm2ddl.auto" value="create"/> is active this error appears
> WARN [ServiceController] Problem
> starting service
> persistence.units:ear=we...
We have an application (Java) with an own OR mapper. Within this system we have what can be compared to Hibernate's interceptors (we call it triggers): Do specific actions just before saving data in the database, after it's deleted and so on. The underlying database is MySQL.
Now we would like to use tools such as Pentaho Data Integrati...
We (will) have the following architecture:
Base.war will be a self-contained spring-hibernate application
All applications will run under Glassfish, and may be clustered
E1.war will sit on top of Base.war, extending it's functionality
There could be further extensions (E2.war, E3.war, ) sitting on top of Base.war
Either wars could star...