hibernate

Map database column1, column2, columnN to a collection of elements

In legacy database tables we have numbered columns like C1, C2, C3, C100 or M1, M2, M3, M100. This columns represent BLOB data. It is not possible to change anything it this database. By using JPA Embeddable we map all of the columns to single fields. And then during embedding we override names by using 100 override annotations. Recen...

Unreliable Hibernate Objects

I've run into a situation where the Hibernate object passed back from the query is unreliable. Consider the following code: MyClass myClass = myDAO.get(id); myClass.getId(); //This works myClass.getName(); //This returns null sometimes, and works sometimes Here's my get Method: @SuppressWarnings("unchecked") public T get(ID id) { ...

simple hibernate session management

hello good people! i'm a bit new in the world of hibernate and i lack knowledge in certain domain when it comes to java.I know for a fact that a good piece of software that uses hibernate use a session manager that can provide different kind of session.i'll like to create for now a simple session manager on top of which i'll build gradua...

How to know what made a hibernate persisted object dirty?

An object I mapped with hibernate has strange behavior. In order to know why the object behaves strangely, I need to know what makes that object dirty. Can somebody help and give me a hint? The object is a Java class in a Java/Spring context. So I would prefer an answer targetting the Java platform. Edit: I would like to gain access t...

How can you replicate Hibernate's saveOrUpdate in JPA?

In JPA, is there any way you can replicate Hibernate's saveOrUpdate behavior, saveOrUpdate public void saveOrUpdate(Object object) throws HibernateException Either save(Object) or update(Object) the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-val...

Loading javassist-ed Hibernate entity

I have a JSF converter that I use for a SelectItem list containing several different entity types. In the getAsString() method I create the string as the class name suffixed with ":" and the ID. MySuperClass superClass = (MySuperClass)value; if(superClass != null) { return String.valueOf(superClass.getClass().getName()+":"+superClass...

In Spring with jpa/hibernate, how do I keep a session open to avoid lazy initialization exceptions?

I currently mark collections in entity beans as eager to avoid getting a lazy initialization exception when I try to access the collection properties after loading the bean with the EntityManager. If I instead leave the collection as lazy loading, how do I keep a session open? I thought about trying @Transactional, but even if that work...

HSQL Subqueries

Hi there, I have a class Order that contains a set of OrderSection's that itself contains a set of OrderItem's. In SQL, one can use a SELECT statement in a JOIN clause as done in the following query: SELECT o.id, o.amount, sum(s.quantity*s.price), sum(s.quantity*i.price) FROM orders AS o JOIN ordersections AS s...

Tools for Performance Testing Grails Wep Applications

I am searching for an Tool to test an Grails Wep Application on a Tomcat Server. I need some Data about the Performance when 30 Users work with my app.(Creating/Editing/Deleting Entries on my Database (Firebird). ...

Db migrate - Hibernate/JPA - hbm2ddl - diff tools...

Hello I use - EJB3 / JPA (hibernate) - MySQL 5 I have to set up a system to help database migrations. Tried to use LiquiBase but it seems not enough mature yet to be used with Hibernate. What i would like to do is: - I have version 1.0 of the application in production - I have version 2.0 of the application developped and tested - I ...

Lazily loading a clob in hibernate

There's a lot one can find about this googling a bit but I haven't quite found a workable solution to this problem. Basically what I have is a big CLOB on a particular class that I want to have loaded on demand. The naive way to do this would be: class MyType { // ... @Basic(fetch=FetchType.LAZY) @Lob public String getBlob() ...

working with one-to-many relationship in hibernate

hello good people.I'm still learning what hibernate can do and this time i'm trying something that seems not to be working. i have 2 tables users and contacts.as you can guess contacts hold the relationship by have user_id as foreign key. here are snippet of the 2 mapping files. this first is from users.hbm.xml <set name="contactsdetail...

how to configure hibernate to work with apache cxf

To my application I need to use hibernate with apache cxf. Problem is after I configure hibernate to apache cxf, application didn't start. It gives an error saying it cannot find the LocalSessionFactoryBean class from the springframework (which I used to create the factorySession). I'm new to apache cxf, so it could be an error in my par...

NetBeans refactoring Hibernate mapping files

Hi there, When I do a refactoring such as renaming a field in netbeans, the hibernate mapping files are updated accordingly. This could have bean a good thing if the whole files were not completely reformatted. So I would rather not have this feature. Is there a way to disallow the modification of hibernate mapping files by netbeans? ...

some Hibernate Question

I have 2 question I wanna make Mysql table that have charset utf8 but I don't know where I shoud set the setting. (I just have a hibernate.cfg.XMl no any .xml file for hibernate) i dun want set mysql.ini file that default setting was UTF-8 I wanna put this setting in my hibernate. second Question: I have this table: CREATE TABLE `bui...

HQL Problem

Hi every one I have these classe @Entity @Table(name = "login", uniqueConstraints={@UniqueConstraint(columnNames={"username_fk"})}) public class Login implements Serializable { @Id @Column(name = "id") @GeneratedValue private int id; @Column(name = "password", length = 64) private String password; @Column(na...

How to make Divide(column1/column2) in hibernate criteria projections

Hi, I am new to Hibernate. I need to perform select item.itemName, (item.Qty * item.Price) as total Price from Item item' in Hibernate criteria query. i tried, objCriteria = objSession.createCriteria(ItemVO.class, "IT") .setProjection(Projections.projectionList() .add(Projections.property("IT.name"), "itemName") .add(Projections.sqlPro...

@ManyToMany Hibernate Question (can add extra field?)

Hi every one, I have these two class(table) @Entity @Table(name = "course") public class Course { @Id @Column(name = "courseid") private String courseId; @Column(name = "coursename") private String courseName; @Column(name = "vahed") private int vahed; @Column(name = "coursedep") private int dep; ...

problem with basic attributes java.sql.Blob

Hi every one, I have this code @Entity @Table(name = "picture") public class Picture implements Serializable { @Id @Column(name = "id") @GeneratedValue private int id; @Column(name = "format", length = 8) private String format; @Basic(fetch = FetchType.LAZY) @Column(name = "context", nullable = true, co...

Does anyone know if Hibernate and java will work effectively with Access?

I have a small project that doesn't require much disk space, so i considered using an access database. I was wondering if anyone used a Spring + Hibernate + access combination, if so can they post the connection properties. thanks guys ...