Lakshmi Dasari

Ranch Hand
+ Follow
since Mar 03, 2003
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lakshmi Dasari

You can use the tag mutable="false" in the class declaration of the hbm.
Does anyone know if hibernate supports row-level security implementation and if any configuration/code changes can be done on hibernate to use this feature provided by oracle. There is very little information on this available, so it will be great if anyone can throw some light on this.
We have a multi-tiered application with as many as 750 and odd tables mapped using hibernate. In one of the layers, we require the domain objects mapped using hibernate, to be converted to value objects as the usage of these value objects is totally different. (This is an architecture decision and nothing much can be done to change this).

Keeping the volume of conversion code to be written in mind, a program was written to automatically convert the DO-VO and VO-DO using reflection. As expected the logs are full of LazyInitializationException. This becomes a problem as it is difficult to debug as the logs are filled with these exceptions.

We explored checking every object with Hibernate.initialize() before converting, but this is still not helpful in case of proxy objects where only the primary keys are populated and other properties are not initialized. So this still results in LazyInitializationException.

Modifying hibernate source code and removing the logging statement seems to be the only option.

Are there any more options I can try, before changing the source code?
I observed that on using CompositeUserType,
when I save an object which contains the property defined by CompositeUserType, the SQLs generated are an insert statement
followed by an update statement with only the fields in CompositeUserType.

My application is very sensitive to the SQLs generated
as there are triggers on update statements and
this results in a pseudo update in my audit tables .

Is this a bug with hibernate or is it the expected behaviour ?

Hibernate version:
Mapping documents:


DB script

Name and version of the database you are using: HSQLDB
The generated SQL (show_sql=true):

insert into A (a1, a2, A3, A4, A5, id) values ('1', '2', '', '', '', 3)
update A set A3='6', A4='7', A5='8' where id=3
[ May 18, 2007: Message edited by: Lakshmi Dasari ]
Is it possible to map similar type of columns to one property (or rather in a set or array)?

For Eg:

I have a denormalized table where I store individual tooth information in each column of the table say col_tooth1, col_tooth2, col_tooth3 ...col_tooth32 . Rather than having a one-to-one mapping of a column to a property in the persistent object, I would like to store all the information in an array of length 32.

Is it possible to do this kind of mapping in hibernate. Hibernate Sets/Lists represented multiple rows in a table. Can they be used to represent multiple similar types of columns instead of rows?
The method which has the transaction boundaries marked is a session bean method. The exception is getting caught in the session bean methods instead of the DAOs.
I have try/catch blocks in DAO around and session.update, but the exception is not caught there as the focus shifts to where the transaction boundaries are marked. Because of this datalayer exceptions are exposed to the facade layer rather than the DAO layer.
I have a query on the usage of container managed transactions and explicit usage of session.flush(). From what I understand, if I demarcate a method boundaries with CMT Required option, then JTA takes care of associating the current session with the transaction, beginning, commiting the transaction and flushing and closing the session at the end of the transaction.

Now, if I have a method marked with CMT, which performs two DML operations, say and session.update(object), both
the statements are executed to the database at the time of transaction commit. This results in transaction rollback if any of the statements fail.
Now if I would like to handle the failure of one of the statements exclusively, I am unable to do so as JTA is flushing my session at the end of transaction. Meaning the exception is not caught in the try/catch block wrapping

Can I force the session.flush() after in CMT? This will force the statemets to be executed to the DB giving me the chance to handle the failure. I have seen that this works quite well for me. as I can explicitly rollback the transaction by setting sessionContext.setRollbackOnly() which rollbacks both the DML statements.

I want to know if there are any repercussions of handling session directly in CMT that I am not forseeing? Is it safe to call session.flush() in CMT?
Rather strange requirement. Are you having cache definitions in both the configuration files ? And are you sure the cache is being hit when using SessionFactory2 and not the database?
try type="yes_no" in your property mapping in hbm.xml and use a boolean datatype for the property in your pojo instead of Boolean. "yes-no" type converts 0 to false and 1 to true boolean datatype. And not-null="true" only tells that at the time of insertion/updation of a record through hibernate, null value is not acceptable. In your particular case, you could think of updating your database if its not a prod database and/or giving a default value for this column in the database table so that you would not encounter a null value.
You can use hibernate's "PersistentClass" to get the entity mapping information at runtime. You can get the mapping class for a persistent entity say "User" with the code below and explore the Table class apis for getting the columns of the table. For Eg:

Firstly is "J001 " a valid value in your application? if not then its just that the database is not consistent. Perhaps you could think of trimming the data before inserting into the database table and query by "J001". Hope this helps
You need to enable statistics inorder to see the hit / miss ratio. Make sure you have the property

enabled in your hibernate configuration file.

[ January 01, 2007: Message edited by: Lakshmi Dasari ]
[ January 01, 2007: Message edited by: Lakshmi Dasari ]
Has anyone tried getting Hibernate sessionFactory Statistics MBean working on Websphere appserver 6.0? If yes, can someone provide the guidelines please. I could create Hibernate as a service in Websphere and initialize hibernate at server startup time, but am unable to find out how to get statistics as an Mbean on Websphere application server. I will post the solution if I manage to do it myself.

Thanks in advance !
Just to confirm, hibernate.cfg.xml overides the properties in file if both are present.