hibernate

Do I need external 2nd level cache for multiple NHibernate instances in Windows Azure?

I am developing AMF Flash gateway on FlourineFx application for deployment on Windows Azure and I want to use Azure SQL. I use NHibernate 2.1 + NHibernate.Linq 1.0 + FluentNHibernate 1.1 There will be two or more instances of this FlourineFx gateway and only 1 database. I am planning on implementing memcached as 2nd level cache later ...

Hibernate log4j.properties print DB uname & pass

My story is as follows. I have a java app with hibernate connected to a embedded db(derby). The funny thing was, that my hibernate app printed the uname at start, because i was using slf4j-simple, and so i set my App to use log4j. Hibernate db uname&pass are set in code, using property object. I tried using the same trick on log4j prope...

Hibernate onetomany mapping

Hi folks, I try to map a relation for the first time. I have found a lot of ways to go. There are two classes: - Project (Parent) - Application (Child) So one project can have several applications, but one application belongs to just one project.. I constructed them as follows: Project.java import javax.persistence.CascadeType; ...

JPA/Hibernate mapping dynamic columns as a List of objects

I have an existing DB schema which I'm trying to ORM'ise with JPA/Hibernate annotations. The schema is designed to allow for clients to assoicate extra information with each row in a table. Rather than using a key-value pattern the existing solution determines the required number of dynamic columns at install time, and alters the table t...

Finding an inverse relation in the Hibernate metadata

Hi, Hibernate exposes its data model through the Configuration object, where I can access PersistentClass and Property objects. Some of the Property objects describe a relation between two PersistentClass instances. For example, if I have a one-to-many relation between Person and Address in my model, and a many-to-one inverse relation ...

Hibernate - how to model triple join table as map?

Hi! I have a problem with mapping triple join table as a map with Hibernate using annotations. I have 3 tables: project, group, role and triple join table project_group_role with columns project_id, group_id, role_id (primary key is a pair of project_id and group_id). Database structure is given strictly from supervisor, so it would be g...

ManyToMany remove problem

Hi guys, I have a table: DocumentType: @ManyToMany(cascade = {CascadeType.REFRESH, CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY) @JoinTable( name = "document_type_property_type", joinColumns = @JoinColumn(name = "document_type"), inverseJoinColumns = @JoinColumn(name = "property_type") ) @Cascade({org.hi...

how to write subquery in hibernate

Hi, i have SQL query , i dont know how to write in hibernate select lp.lnprdtname,la.lid,la.step from mfic.lnapp as la left join mfic.lnprdt as lp on lp.lnprdtid in (select lnprdtid from mfic.lnapp where lid in (select lid from mfic.lnbrwr where brwrid in (select brwrid from mfic.brwr where uid=1))) where l...

List conversion to be used in Struts 2

Hello all, I do the following to return a list contains 2 objects for each item. public List getList(int id) { open(); // TODO Auto-generated method stub List l = session.createSQLQuery("select poDetail.*,quantity*unitPrice as total from poDetail where poDetail.poID="+id) .addEntity("poDe...

Hibernate, HSQL, and Update w/ Limits

Is it possible to limit the number of rows that are updated using Hibernate/HQL? For instance: Query q = em.createQuery("UPDATE MyObj o Set o.prop = :prop"); q.setParameter("prop", "foo"); q.setMaxResults(myLimit); int res = q.executeUpdate(); if (res > myLimit) { // This is entering here and I don't want it to! } I've been Goog...

Hibernate & EhCache: net.sf.ehcache.Statistics not populated?

I think my Hibernate (3.5.3) Second Level Cache is well configured with EhCache (2.2). At least, I observe following log entries: 20:15:28 DEBUG [net.sf.ehcache.Cache#searchInStoreWithStats] persistence.unit:unitName=#pu-pay.c.u.p.model.ActionCache: persistence.unit:unitName=#pu-pay.c.u.p.model.Action store hit for c.u.p.model.Action#T...

how to add struts or hibernate capabilities in Spring Source Tool?

generally by using my-eclipse we add struts,hibernate and jpa capabilities to our applications/projects, like this how to add structs or hibernate capabilities to our applications using Spring Source Tool? Spring Source tool is a version of eclipse ide. ...

JPA Query optimization by avoiding JOIN to lookup table?...

Imagine a table emp: CREATE TABLE emp ( id NUMBER , name VARCHAR , dept_code VARCHAR ) and a table dept: CREATE TABLE dept ( code VARCHAR , name VARCHAR ) emp.dept_code references dept.code as a ForeignKey. These tables are mapped to JPA Entities, and the ForeignKey is modeled as an association...

parent-child relation, cascade-save with generated parent-key as foreign key in child table

I have two tables in parent child relation. Parent can have multiple child records. Primay key of parent table is generated by hibernate, this generated primary key of parent table is foreign key in child table. There is cascade=all set in parent hbm. So after parent key is generated and parent record is saved, child record should get sa...

How to use JPA2's @Cacheable instead of Hibernate's @Cache

Typically , I use Hibernate's @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) to cache an @Entity class , and it works well. In JPA2 , there's another @Cacheable annotation that seems to be the same functionality with Hibernate's @Cache. To make my entity class independent of hibernate's package , I want to give it a try....

How do I map entities to a common table with Hibernate?

I have a few simple entities that are stored in a simple "code" table with the following structure (all stored as character fields): code_fieldname pk code_value pk code_comment code_field1 code_field2 One object I am trying to map has data stored in this table of the following form code_fieldname = "segment" class = Segment ...

Strange hibernate exception when running under Linux

I have a project that compiles and runs completely fine under OS/X, but under Linux an exception is thrown that gives no clue as to what might be the problem. I've been stuck on this for hours trying to narrow it down, any pointers would be helpful! java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) ...

How to handle @JoinColumn in your own NamingStrategy implementation?

I thought that joinKeyColumnName() handles @JoinColumn, but in reality I could not get it to work. I want to get rid of the necessity to write name="" in @JoinColumn I want the property to be used as the column name. ...

Hibernate retrieving list from onetomany

Hi guys, I managed (as you can see in older posts from me) to insert a onetomany relation through hibernate. My two entity classes look like following: Project.java: @Entity public class Project { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; @OneToMany(cascade = CascadeType.ALL, mappedBy="project") ...

What is the difference between cascade & inverse in hibernate, what is the use of them?

how to use cascade and inverse in hibernate, what is the procedure/tag to define them? is they relate to each other? how they are useful in hibernate... ...