Saeed alkhen

+ Follow
since Feb 11, 2009
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 Saeed alkhen

Dear Vijitha Kumara,
Thank you very much for your response, For the ID generation: this table has a composite primary key (Department_Id, Correspondence_Site_Id), both of them is foreign key to another table.
And for your second question: I can't got your idea, could you please repeat it in a clearer way.

Thanks and best regards,
Hi everybody,
I'm facing the following error in Hibernate : More than one row with the given identifier was found while I'm trying to merge the object.

Details :
  • I'm using Spring 2.5, Hibernate 3.0 and my application deployed on Websphere ver 7.x
  • I applied the DB Session per HTTP request methodology (not the spring implementation) but I used the ThreadLocal to save the session to be used again within the current HTTP request, and once the response is ready to be sent to the client I have a HTTPFilter to close any opened session in this Thread.
  • I got the error once I have a bulk operation on the DB within one HTTP request (Deleting, Updating, Merging, Inserting,.....)
  • I used the JNDI datasource managed by Websphere itself
  • I was thinking like following: At the starting point of my request, I asked the session factory to provide me a session instance, and I used this session in my request until I closed it at the end of my request processing. and the hibernate merge method try to load the object before merging it, once the query for loading is executed: the exception is thrown telling me that (More than one row with the given identifier was found), for me this means that the object is loaded to the current session before, so the first stupid idea was to flush and close the current session before merging and start a new one just for this merging, I did that but I faced the same error, that means I was thinking wrong from the beginning.
  • The second approach I'm trying to follow is to separate this bulk operation to multi operations done directly in separate ajax request (Suppose I have a grid with update and delete functionality for each row, I allow the user to update and delete whatever he wants and I cache these changes until the user click "apply" button to apply all thees changes, the new Idea is: once the user tried to delete a row a new HTTP request (with DB session) will be responsible for deleting this row in the database, in this case no more need to the apply button because the modifications a reflected directly to the DB)

  • Please help me.

    Try this :

    and then
    10 years ago
    Hi All...
    I faced the same problem about get the applicationContext from the business layer and i follow the solution above and it worked correctly, thank a lot for your help. But my question now is :
    What if a want to get a session scoped bean from the application context in business layer

    In other word and with some details:
    My Application implements the 3 layers as follow:
  • Icefaces for presentation layer
  • Spring for business layer
  • Hibernate for persistence layer

  • and i used acegi security to secure my application...

    Now after the user enter the login information the acegi started the authentication process and i use a custom LDAP authentication provider to check the login information in the Active Directory, and this custom provider is registered in the applicationContext.xml file.. In this case i suppose that this provider is in my business layer. In this provider and after he finish his work with Active Directory i need to get the application context and get the session scoped bean "user", and inside this bean i need to save my login information..

    So what i did till now: create my custom provider which is worked successfully and I implement the Interface "ApplicationContextAware" and override the method "setApplicationContext" and I get a reference to the application context which held in the "appContext" variable, after that I let the Provider to do his work and after that I invoke the method appContext.getBean("user") and i got an error message that told me :
    "Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to req...."

    So what is the solution .... ??? .. anyone can help my .... every suggestion or help will be appreciated