I am trying to map a JPA (using Hibernate) one-to-one relationship with a inheritance strategy TABLE_PER_CLASS. Here is an example:
@Entity
public class DrivingLicense {
@OneToOne(targetEntity = Human.class, cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@JoinColumn
private Human human;
@SuppressWarnings("unchecked")...
I am using Hibernate/JPA to execute native PostGIS queries. The problem with these queries is that they need parameters that are not of the classical X = 'value' form.
For example, the following lines crash
String queryString = "select * from Cell c where ST_DWithin(c.shape, SetSRID(ST_GeomFromEWKT('POINT(:lon :lat)'),4326), 0.1)";
...
I'm trying to build JSF application and I'm using hibernate as ORM solution. The problem is that I got my code full of replicate code
Transaction tx = null;
Session session = SessionFactoryUtil.getInstance().getCurrentSession();
try {
tx = session.beginTransaction();
tx.commit();}
catch(Exception){}
in every function. Can spring...
I have a Hibernate criteria query that is incorrectly pulling out max results. In many cases, when I specify 20 max results, the query actually only returns 1 or 5 results, because the restrictions return many duplicates.
Criteria c = session.createCriteria(DomainObject.class);
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
c.cr...
Hi all,
I recently added new property in one class, its list property and I have written xml mapping for that property,due to few reasons I am not suppose to delete database or use create option in hibernate config file to update changes. I have to do it manual by executing sql queries on database.
xml mapping file:
<list name="items"...
I'm developing a JEE6-application, using JPA 2.0 and Hibernate 3.5.2-Final as the Provider (and MySQL 5.1.41). My Application Server is Glassfish V3.0.1.
I already have a working CRUD-app with some entities and relationships.
Now i added an (really simple) entity with the name "Group". The entity class looks like this:
package model
//...
I get an error message as java.lang.reflect.UndeclaredThrowableException and Invalid column name. Can you help me why am i getting this error.
...
Hi,
I have a problem removing the parent entity from the database. The code looks like this:
public class Parent implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchTy...
Hello, I've searched on the internet but I didn't understand very much the problem:
I'm trying to build a distinct query using criteria and a distinct clause using a projection, trying to resole the lazy attribute of the projection in the distinct.
So the query will be like this
Code:
createCriteria(Parent.class)
.setProject(Pro...
How do I tell Hibernate to create a primary key for a many-to-many relationship in an .hbm file?
...
Hi Everyone,
I'm running into an issue reconstituting an object from the database using Hibernate. An @Embedded component is throwing a NullPointerException when it's being accessed for the class' hashCode() implementation.
The reconstitution is attempting to be done thus:
@Override
public Collection<Web> getWebs() {
Collection<?...
I'm using Hibernate 3.5.2-FINAL with annotations to specify my persistence mappings. I'm struggling with modelling a relationship between an Application and a set of Platforms. Each application is available for a set of platforms.
From all the reading and searching I've done, I think I need to have the platform enum class be persisted a...
I'm using Hibernate JPA.
Suppose I have these classes:
AbstractPerson
|--> ConcreteEmployee
|--> ConcreteCustomer
Is there any way to make the concrete classes have independent IDs?
I'm using InheritanceType.TABLE_PER_CLASS.
...
Hi all,
I have tables, called Customer, Orders.... Each table contains createdBy, CreatedDate,ModifiedBy, ModifiedDate. How do i fill this information for all tables without duplicating these columns in each entity and mapping file? I am using Java 1.4, hibernate ORM model.
Currently i have create one base class (CoreDomainObject) which...
Hi All-
I defined a second level cache in my application using @Cache annotation
I am using findById query, as the following:
long id = 4;
Company cmp = companyDAO.findById(id);
Where Company is the object that I get from the DB.
How can I check if the Company object came from the DB or from the cache?
...
Hello!
I have a bidirectional n:m relation with two entities and I have created domain objects for using with Hibernate in the latest version 3.5.3.
I used this for my example:
http://tadtech.blogspot.com/2007/09/hibernate-annotation-many-to-many-join_03.html
My problem: The Addres will be added without a problem. But it does not make ...
Hi,
Im doing a JMS project.
can anybody point out a reference on running ActiveMQ(JMS) on two different pc using eclipse on both pc?
tnx
-jaded
...
Hello I am using hibernate + spring since 5 months but never used stored procedure in hibernate so please can anybody tell me how to call stored procedure from DB(MySQL)....
...
I use Hibernate 3.5.3, and Oracle 10g database
I have bean with following relation
@OneToMany
@JoinTable(name="dispenser_accounts",
joinColumns=@JoinColumn(name="terminal_id"),
inverseJoinColumns=@JoinColumn(name="dispenser_section_id"))
@MapKey(name="dispenserNumber")
private Map<Integer, DispenserAccount> activeDispe...
I'm trying to write a test that isolates the failure to load a property because no Session exists.
The following path fails
ERROR [http-8081-14] LazyInitializationException.setSessionAttribute(223) | could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hib...