zabet tyan

Ranch Hand
+ Follow
since Jan 14, 2009
Merit badge: grant badges
For More
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 zabet tyan


I am using detachedCriteria to retrieve something from db.

I have notification hbm as follows:

Person is not mapped directly to notification. it has the id only.

the person has a displayName field that I want to get and return as part of my Projection.

However I am not sure how to join the tables using DetachedCriteria to get the field.

Please note I cannot change the database model or hbm files.

Any help would be greatly appriciated,


I am getting this exception:

I read somewhere online that I have to wrap my the classes in transactionProxies. I am doing so for wfControllerMdb which is a MessageListener and where the initial request is made.

my initial call at the top of the stacktrace is wrapped in a proxy:

I am also doing in my OrderManager which makes the final call to my entityManager to save:

and my entityManager which is in charge of saving is also wrapped in a transcationProxy:

So WFControllerMdb (wrapped in txProxy) calls a couple of objects:

those objects get the OrderManager bean from my beanAwareFactory (wrapped in txProxy) and call updateOrder.
then OrderManager(wrapped in txProxy) calls entityManger (wrapped in txProxy) to save the order.

I am pretty sure that no where in my code any transaction is marked as readonly, so the question is why am I getting this error message.

THanks a lot.
12 years ago
There is a config file that contains some information. Depending on some value in config file, say x = 4, I have to create 4 B objects.

Right now I set object B to have prototype scope in spring config and use beanFactoryAware to get the B object. Object B depends on object C and needs spring to inject it.
13 years ago

Well I am running away from EJBs. So don't want to keep any EJBs around. Anyways, I redesigned that section, but had to have one of my class implement BeanFactoryAware.
13 years ago
Thanks Mark,

Yes I am porting my project over from jboos/ejb to tomcat/spring so need to do a lot of design reviews regardless i guess. thought maybe spring has some quick and easy fix so I don't have to work too hard...
13 years ago

I have a class A registered in my ApplicationContext.xml.

At some point, class A creates object B,

b has dependend on bean C which is injected into it.

How do I make Spring aware of the fact that B was created so that it can inject the required dependencies?

I thought of making my A class BeanFactoryAware, but that doesn't sound like a good idea.

Note that I might have to create several B objects that must be initialized.

I cannot inject class B to class A.

13 years ago
Finally after days of beating myself in the head with a hammer I solved the problem!... only if could read more books

anyways here is the solution, wrap the messageHandler in transactionProxy

Now off to the next problem
13 years ago

Can someone point me to a document/site that could help me figure out how to get hibernate session inside onMessage method of a MessageListener?

When I inject a finder in my messageListener, I always get org.hibernate.SessionException: Session is closed!

Here is what I have so far:

and findAreaByName :

and my entityManager code:

13 years ago

I am using a ActiveMQQueue and I have a class that processes the messages. Everytime the onMessage is called, and my finder executes findAreaByName, i get "Session is closed!"

I tried to make IncomingMessageHandler FactoryBeanAware and get finder at runtime but it didn't work. I tried to make finder of prototype scope, but that didn't help. Any ideas on what could be the problem?

is it because I am using DefaultMessageListenerContainer?

and findAreaByName :

and my entityManager code:

13 years ago
I used merge() and everything seems ok now. But the question remains...why does hibernate update something that hasn't changed?!

I have the following problem:

I have an Activity class that maps to table activity.

I have a Profile class that maps to profile table. Everytime the profile is updated I create a ProfileHistory object and save it in profile_history table.

The history should never be modified.

Now in special cases I want to associate the Activity with ProfileHistory in activity_profile_history_xref table which only saves the id of the activity and profile_history:

Here is the related hbm file in Activity :

Now here is the problem:

profileHistory has an attribute Facility. ProfileHistory objects could be pointing to the same Facility object.

Hence when I retrieve multiple profileHistory objects that point to the same Facility object and associate them to Activity and then save the Activity object, I get

a different object with the same identifier value was already associated with the session [for Facility object]

And the problem is that hibernate is trying to update the profileHistory, while nothing has changed on the profileHistory side ( I can tell from the hibernate sql statements).

Is there a way to force hibernate to just update the Activity object?

So far my only solution was to do something like this:

Could someone suggest a better way?

Thanks in advance.


Yes download HibernateTools for eclipse from it will generate everything.

although it is a good practice to do everything on your own first to learn how things work.

Finally got it:

Just looked at how jboss names the ejbs when it loads ejbs:

Thanks for your help.
13 years ago

I have the following problem:

I have two tables

profile and profile history.

These tables have their own back reference tables to an area. (so a profile can have many areas and the history has to keep track of that)

for profile- area:
aac_profile_area_xref: profile_id(FK) and area_id(FK)

for profile_history_area:
aac_profile_his_area_xref: profile_history_id(FK) and area_id(FK).

the area has a version column so hibernate keeps track of every update:

Here is the related part of the hbm files:

for profile:

for profile history:

Now here is the sequence of events that are happening during a profile save (assuming an area is already persisted):

create a profile object.
create a profile history object.
save the history (which updates the area!)
save the profile (which tries to update the area but I get StaleObjectStateException !)

(profile and history are saved in two separate transactions)

Now what I want is a way to force hibernate to not update the area when it is saving it. i.e. just put the area_id and profile_id in the back reference table of the history.

Is there anyway to do this?


I tried both suggestions in the post. Still no luck... it gives the same error message.
13 years ago