Daniel Jabonete

Ranch Hand
+ Follow
since Apr 01, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Daniel Jabonete

Hi Fritz,

I had tried your implementation codes and steps to hit the exception. I ran these codes in a web setting using two browsers with respective Session ID.

Although, I was able to lock the entity and the other user wait until the first user commits his changes, it seems there were different exceptions with each scenarios, especially when the lock expires. I encountered “javax.transaction.NotSupportedException: Nested Transactions are not supported” and “java.lang.IllegalMonitorStateException”, that I believed can be treated easily, hence based on these tests the “PessimisticLockException” seems not that easy to get around and can be thrown as an explicit exception, as we intended it to be.

I will still try and search a couple of resolutions in order to attain a much direct or straight-forward approach, and will post it here.

My apologies for my late response to this post.

If you guys still have other ideas or codes that you would like to show or share in relation to this topic/subject, please don’t hesitate to post it here.

Thanks very much!

Cheers!
Daniel
Hi Rafael,

Its seems these were the case. It started a transaction and closes it once done.

I am calling a flush from the Entity Manager to commit the update immediately to the database.

Hence, from your reply with regards to the behavior of "Stateless" Session Bean, I create a "Stateful" Session Bean with an extended Persistent Context Type, please see below:



From these changes I still cannot hit the "PessimisticLockException". It seem that the only way to throw this exception is to compare the before & after state of an entity and throw it manually.

Sorry for the late response.

Any more ideas or insights about this puzzle.

Thanks!
Hi Rafael,

The test scenario would be User1 and User2 accessed the Web Application, then querying the Employee table and list it after find all.

Both users selected the same Employee record with the intention of updating the salary. User1 acquired a pessimistic lock to Employee 10001A at the other end User2 also selected Employee 10001A with the intention of updating the salary. Up onto this point User2 should not be able to acquire a lock to the record since User1 acquired an exclusive pessimistic lock to it.

Should the Pessimistic Lock Exception had been thrown here or if User1 commits his update and User2 also made his with stale copy of the entity?

I am trying to trigger or hit the "PessimisticLockException" in a Web Application context using a stateless session bean with an Entity Manager locking each entity with Pessimistic Lock Type.

Any thought or insights in relation to these?

Thanks very much, appreciate it!

Cheers!
Daniel
Hi Rafael,

Thanks for your reply!

As for my test and setup, I am using a single Entity Manager and in a Web Application accessing by concurrent users.

Although, OptimisticLockException would be sufficient, and I am thinking of eagerly or exclusively acquiring the lock for an entity update.

Any ideas?
I think the "javax.persistence.PessimisticLockException" can be triggered by setting the lock timeout to "0", but it is considered an issue, please see reference bug filed under "Bug 326424 - SELECT FOR UPDATE *NOWAIT* causes syntax error on MySQL".

I was hoping to hit or trigger the "javax.persistence.PessimisticLockException" by using the Entity Manger's find method, passing the Pessimistic Write Lock Type then lock the entity and proceed with the update. And then the other user who tries to update the same entity (with a stale values of the entity) will get the exception. This might also sound optimistic locking, but the main idea would be that the other user cannot update the same entity the 1st user locked for update.

Any ideas about these matters?

Thanks!
Greetings!

I would like to kindly ask how to trigger or hit a “javax.persistence.PessimisticLockException” runtime exception upon locking an entity.

I am hoping for your assistance, and insights in relation to this question.

Thanks very much in advance, I appreciate your time and effort!

Best regards,
Daniel
Greetings!

I found where the problem lies in my code.

Primarily, it was not on the @ElementCollection or @CollectionTable annotation configurations, but rather on the Department relationship @OneToMany annotation. In which by default has a fetch Type of “javax.persistence.FetchType.LAZY”, so the moment I executed the “SELECT” query statement in my “FindAll” button the Department entity didn’t eagerly load its employees.



I hope this serve as a reference resolution for those who are encountering similar problems with JPA 2.

Thanks very much!

Best regards,
Daniel
Greetings!

I would like to kindly ask some help with regards to my weird problem in JPA 2.1 @ElementCollection/@CollectionTable mapping.

I have created the mapping below:



I was able to add, update, and read records from my Database. The issue arises when stop my local web app then start it again, and test the “FindAll” button that executes the select statement for getting the entire Employee in the table.
It hangs and there were logs exceptions that have been thrown, please see below:



I am not sure if I missed something or there are existing bugs in relation to this, but I already upgrade to the latest version of EclipseLink and MySQL Connector for Java.

I am hoping someone already encounter these particular anomalies when trying out these use case in JPA 2.1. I appreciate any help you could impart.

Thanks very much in advance!

Best regards,
Daniel

Great discussions there Jared!

Seems this thread has been awaken once more. You've mentioned a lot of good points out there, most especially when it comes to composing each applications/portlet for the portal.

The separation of views or pages per web application in a portal can really be a great deal (+1 points) for Portal/Porlet Development.

Although, I am not pretty much sure about the slowness, perhaps that can be resolved during performance testing and tuning phases.

Another side I am looking at would be the time-to-market (or hosting) the application, if the application is for public consumptions, there are few hosting companies out there that offer good services when it comes to java hosting.
They are at most only offering tomcat container for deploying your web applications, and I am not sure if there are good hosting companies or service out there that can cater for Portal/Portlet deployment.

I am mentioning this area for Portal/Portlet Development since some how if we development a good applications out of it, but we cannot get it out of the market (if we are operating by our selves for example), then it is a problem.
But if some corporations will do this deployment for you or you are working for company that is doing Portal/Portlet Development then its fine.
10 years ago
Greetings!

I would like to kindly ask if there were questions pertaining to XML, Deployment, Testing, and Migration in the exam?

Thanks very much in advance!

Cheers!
Daniel
Greetings!

I am hoping you could kindly help me with the error I am encountering as describe below.

I am trying to separate my entities via package, like the following below:

- manyToManyMap.model.Employee
- overrideCollectionTableColumn.model.Employee

And I am trying to define a separate persistence-unit in my persistence.xml for each package, please see below:

But went I tried to deploy it in Glassfish 3.1 from Eclipse (Juno) the following error prompts:

I am not sure if this is a bug, or I am missing something in JPA 2.0. I already tried to provide different name for each "Employee" entity, but there was an error in persisting an object.

Is there a work around for these scenario, or I might just need to create a separate project for each persistence unit.

Thank you in advance for your insights, time and assistance.

Cheers!
Daniel
Greetings!

In today's Cloud Computing, SOA and Web Services, where every aspect of distributed computing can be transmitted by public and private servers using these technologies, what EJB 3.1 technologies can offer to the developers, and businesses that cannot achieved by the later.

Thanks very much!

Cheers!
Daniel
"i would rather die a meningful death,
than live a meaningless life..."
by corry aquino ex-president of the philippines
15 years ago
Hi,

The profiling tools depends in your IDE.

Netbeans has its own profiling, might want ot check out the NetBeans website for the instructions.

Eclipse also has a lot of profiling tools plugins, might want to checkout the particular plugin that might suites you.

Cheers!
15 years ago
JSF
you need to do a profiling for your application to identified the bottleneck.

this way, it will give you an idea of where, and what causing the problems.

cheers!
15 years ago
JSF