hibernate

JPA : Inheritance - Discriminator value not taken into account in generated SQL

I try to use this mapping : @Entity @Table(name="ecc.\"RATE\"") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType= DiscriminatorType.STRING) public abstract class Rate extends GenericBusinessObject { ... } @Entity @DiscriminatorValue("E") public class EntranceRate extends R...

Hibernate: What's wrong with this mapping to a subclass joined on foreign key?

I am experimenting with Hibernate to gain experience. I created a class Person with two subclasses: Student and Worker: public abstract class Person { private Long id; ... } public class Student extends Person { ... } Another class, Employer, has a bidirectional one-to-many relationship with Worker. public class Worker exten...

Hibernate: order multiple one-to-many relations

I have a search screen, using JSF, JBoss Seam and Hibernate underneath. There are columns for A, B and C, where the relations are as follows: A (1< -- >) B (1< -- >) C A has a List< B > and B has a List< C > (both relations are one-to-many). The UI table supports ordering by any column (ASC or DESC), so I want the results of the quer...

Decouple a JPA entities jar from persistence.xml in SE environment

Is there a way to reuse a jar with JPA annotated entities in more than one SE applications (as a dependency)? <jar-file> in persistence.xml is not supported in SE environments so is there another way? ...

hibernate configuration property file MS Access database

Hi all, I have MS Access database and i want to use hibernate as a persistent layer for my application. So needed a sample hibernate config file entries for MS Access database. Thanks ...

What are the best workarounds for known problems with Hibernate's schema validation of floating point columns when using Oracle 10g?

I have several Java classes with double fields that I am persisting via Hibernate. For example, I have @Entity public class Node ... private double value; When Hibernate's org.hibernate.dialect.Oracle10gDialect creates the DDL for the Node table, it maps the value field to a "double precision" type. create table MDB.Node (... val...

Two collections manyToOne to same primary key

Hi, guys, I'm coding a web page in Hibernate-JPA and Oracle. I need the following: I have two classes: Place and Home. I need two collections of type Place in every Home: I do the following: Home: @ManyToOne @JoinColumn(name="ID_PLACES") private List<Places>places1; @ManyToOne @JoinColumn(name="ID_PLACES") private List<Places>Pl...

how to find difference between two timestamp using hibernate query language

Hello I am trying to write an hql query which gives me the number of hours between two timestamp. So, far i am unable to do this. I have used hql hour function but that does not work if the timestamp corresponds to different date. Please provide any input. My hql query is select count(*) from com.xxx.Request as request where re...

Problem of accent between MySQL and Java application

Hello, i have an application with use Hibernate and Mysql. In Mysql i have a blob in my table. When i record a value in this table with accent like é or è in mysql i have a good result (binary) so when i want read into my jsp i have ? instead of é ...

Hibernate Criteria and statistics

We are heavy users of the Hibernate Statistics in our application, but recently came to realize that Statistics.getQueries() does not return any Criteria queries. I realize that the method returns the HQL strings, but it also means that the Statistics are incomplete. I found a few older issues talking about this, but no resolution. http...

How to avoid this very heavy query that slows down the application?

Hi, We have a web application running in a production enviroment and at some point the client complained about how slow the application got. When we checked what was going on with the application and the database we discover this "precious" query that was being executed by several users at the same time (thus inflicting an extremely hi...

Java-Hibernate-Newbie: How do I acces the values from this list?

I have this class mapped @Entity @Table(name = "USERS") public class User { private long id; private String userName; } and I make a query: Query query = session.createQuery("select id, userName, count(userName) from User order by count(userName) desc"); return query.list(); How can I access the values returned by th...

HIbernate query language problem.....

I have a Project class that has a Set of userstories called userStories12many. I'm having troubles trying to get the project that has a certain userstory in its set getComponent(int userStoryID) I think im on the right track but i dont know what i did wrong public Projects getComponent(int userStoryID) { Session session = SessionFa...

Set creation and update time with Hibernate in Xml mappings

Hi, I'm using Hibernate with Xml mappings. I have an entity that has two fields creationDate and updateDate of type timestamp, that have to be filled with the current UTC time when the entity is persisted and updated. I know about the existence of the @PrePersist and @PreUpdate annotations, but i don't know how to use their equivalent in...

JPA : many-to-many - only one foreign key in the association table

I mapped two classes in a ManyToMany association with these annotations : @Entity @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public abstract class TechnicalItem extends GenericBusinessObject implements Resumable{ @SequenceGenerator(name="TECHNICAL_ITEM_ID_GEN", sequenceName="TECHNICAL_ITEM_ID_SEQ") @Id @Column(n...

Cannot add or update a child row: a foreign key constraint fails

Hi All, i am having a user table which has desname as FK referring to des table ,i am trying to add desname in user but i am gettng Cannot add or update a child row: a foreign key constraint fails error. desname is prepopulated and i am selected the same for he user.Where i am doing wrong I ma using mysql and hibernate hbm ...

How to create a Clob in JPA in an implementation agnostic way

Hello I am using Ejb3 and JPA (based on Hibernate and Oracle 10g at the moment) I have an entity that contains a clob @Entity @Table(name = "My_TAB") public class ExampleEntity implements java.io.Serializable { private Clob someText; public void setSomeText(Clob someText) { this.someText= someText; } @Column...

How to execute an update via SQLQuery in Hibernate

Hi, I need to update a joined sub-class. Since Hibernate doesn't allow to update joined sub-classes in hql or named-query I want to do it via SQL. I also can't use a sql named-query because updates via named-query are not supported in Hibernate. So I decided to use a SQLQuery. But Hibernate complaints about not calling addScalar(): ...

Hibernate mapping issue with composite-id

Hi I am using hibernate3 in my java app to access sqlserver 2008 enterprise. The hibernate mapping uses composite id and when i try to load model it returns null. I spent days to resolve it but still no result. Composite id mapping should be used for multiple field based PK, but in my table no such PK, i wonder why the JBoss Hibernat...

Does Hibernate support one-to-one associations as pkeys?

Hi all, Can anyone tell me whether Hibernate supports associations as the pkey of an entity? I thought that this would be supported but I am having a lot of trouble getting any kind of mapping that represents this to work. In particular, with the straight mapping below: @Entity public class EntityBar { @Id @OneToOne(optional = ...