My desired query is to get a list of Course objects that belong to a Category. My objects are as follows:
public class Course{
String name;
List<Category> categories;
}
public class Category{
String name;
Category parent;
}
Since the categories reference each other, they can have an infinite depth:
A
A.A
...
We need to be able to get the associated java.sql.Connection of a hibernate session. No other connection will work, as this connection may be associated with a running transaction.
If session.connection() is now deprecated, how am I supposed to do that?
Thanks,
-Sergio
...
I have a one-to-many relationship and in my HBM I want to include the association for delete purposes. How can I express that without query/loading the related table/object?
Just including a bag or another collection is the obvious answer, but is there something else?
Hibernate 2.2
...
Hello All,
I have two table Part and SubPart. Part table has general fields like id, name, desc etc. The SubPart table has part_id, sub_part_id as composite key. Both of these columns are referring to Part table and has a one to many mapping for each of them, like for each part_id in the Part table there can be multiple entries in SubPar...
Hi,
I am learning Hibernate and just read the chapter "7.2.3 Adding columns to join tables" of the "Java Persistance with Hibernate" book. My goal is to save Item, Category and CategorizedItem in one transaction.
There is a constructor there (page 305):
public CategorizedItem(String username, Category category, Item item) {
// Set...
Suppose I have a:
class Student {
int id;
String name;
List<Course> courses; //Lazily loaded as per Hiberante config
}
Now suppose I have a List students and in order to optimize fetching List for all these students, I was to batch select them rather than letting Hibernate call a separate SQL one by one. I cannot turn off ...
Hi there,
I need to set up multiple Sessionfactories in my app, now I'm facing a problem. I can't use the 2nd level cache at the moment because only the cache from the first factory is returned. Providing a hibernate.cache.region_prefix would solve the problem I guess. How can I supply for each factory a own region per Spring XML config...
Hi guys,
I have a oracle table which contains char(n) type for several columns. I use hibernate tools to create entities objets and this tool map char type in String.
But when I deploy my application, I get an error because Hibernate wait a varchar2 type and not a char type:
Wrong column type in ARBOR.CMF for column CHG_WHO. Found: ch...
I have a problem with changing my spring/hibernate application from MySql to SQL Server.
When Hibernate is updating the database by starting the server he want to creates(by hibernate.hbm2ddl.auto set on update ) the database but a foreign-key fails on following error:
Unsuccessful: alter table table2 add constraint FKDC2DC97ECEB31922 ...
Hello,
After implement Hibernate Monitoring, i have noticed that hibernate execute too much query than it have on the query string table in statistics.
Screen-shots of statistics:
I think, implement hibernate 2nd level cache and particularly hibernate query cache help me to reduce this amount of query execute.
I searched on the web...
Hi All,
In this page:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/transactions.html
I have read that: "A unit of work is a design pattern described by Martin Fowler"
Did Martin Fowler discovered this pattern before hibernate boys and is Martin the only source of describing this pattern?
Regards
...
I have annotation-driven hibernate capabilies on my project.
Now I want to create an index over a column. My current column definition is
@NotNull
@Column(name = "hash")
private String hash;
and I add @Index annotation here.
@NotNull
@Column(name = "hash")
@Index(name="hashIndex")
private String hash;
and then DROP TABLE and resta...
With this HQL query:
SELECT DISTINCT fs FROM FileStatus fs WHERE UPPER(STR(fs.filePath)) LIKE :FILE_PATH
I get:
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
...
Hi, i am working on a small application and I am trying to use Hibernate Annotations to map my entities. I wanted to test if everything is alright when i got this exception :
Exception in thread "main" java.lang.ExceptionInInitializerError
at fr.cc2i.intervention.dao.main.Main$HibernateUtil.<clinit>(Main.java:48)
at fr.cc2i.inter...
Hi all, i have a parent entity Service and a child ExtendedService in a SINGLE_TABLE inheritance.
A third entity ServiceCollector need to include both entites Service and ExtendedService. This is a fixed requirement, and with this design i can realize it using polymorphism.
THE PROBLEM: Very often i need to retrieve ONLY the parent cla...
I've been looking at various hibernate tutorials and samples, for their identity/primary key property, some use a Java primitive type, some uses the wrapper type, that is;
private int id;
vs
private Integer id;
Why and when would I use one over the other, for the entity key ?
...
I have these 2 mappings:
<hibernate-mapping>
<class name="sample.Operator" table="OPERATOR">
<id name="id" >
<generator class="native" />
</id>
<property name="name" not-null="true">
<column name="NAME" />
</property>
<set name="pointCodes" inverse="false" lazy="true" ...
I have a hibernate project, which uses JPA.
my persistence.xml contents is as follows:
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">...
Considering the following model:
@Entity
public class User {
@Id
@Column(name = "USER_ID")
private Long userId;
@Column(name = "FIRST_NAME")
private String firstName;
@Column(name = "LAST_NAME")
private String lastName;
@OneToOne
@PrimaryKeyJoinColumn
private UserExt userExt;
... //getters...
Hi,
I have a class hierarchy like this:
@Entity
@Table (name="call_distribution_policies")
@Inheritance (strategy=InheritanceType.JOINED)
public class CallDistributionPolicy implements Serializable, Cloneable{
----------------
}
@Entity
@Table(name="skill_based_call_distribution_policies")
public class SkillBasedCallDistributionP...