[Persistence, JBoss/CMP, Hibernate, Database] - Concurrence problem?
by maykellff
I have the following situation:
I'm using Spring 2.0.6, hibernate 3.2 and Oracle 10g
There is a table that concentrates a lot of traffic in the application (it is an auditting table) and from time to time it produces a "JDBC can't execute batch update" exception. I believe this is because there is a lot of concurrent access to this table in the database, but I have no proof of that...
The problem may stem from the way Hibernate treats the autogenerated id columns in Oracle. Hibernate issues a select max(id) first, and then uses this number to persist the instance at hand. If there is a high concurrence situacion, I believe is possible for Hibernate to retrieve the same index twice and to try and persist the entity with that id more than once, thus getting the aforementioned error. Again, this is all speculation, I'm to new to know for sure.
But anyway, asuming the problem is concurrence, I want to try the following:
To declare a singleton bean with one private static attribute indexCount accesable only through a public static getCurrentIndex() method that do something like { return indexCount++;}
How safe is this solution, considering many threads asking indexes simultaneously? Is there some built-in mechanism in Spring that can help me achieve something like this? And since we're at it, Spring does anything at all to ensure threadsafe behavior in stateful singleton beans?
Thanks in advance,
Maykell.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129488#4129488
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129488
18 years, 2 months
[EJB 3.0] - EntityManager is null
by kgreene
Hi,
I'm trying to create a class that does database retrieval using entity manager. When I call getVpInfo, I notice that the entity manager is null. I need to access this dao from another class in my app. I am not accessing the dao from the client-side code.
Does anyone know why the entity manager is null. I have also included my persistence.xml
=======
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless
public class VpInfoDAOBean implements VpInfoDAORemote, VpInfoDAOLocal{
@PersistenceContext (unitName="VPInfoDB")
protected EntityManager em;
private static VpInfoDAOBean dao = new VpInfoDAOBean();
public static VpInfoDAOBean getInstance() {return dao;}
public VpInfo getVpInfo(String appGroup)
{
if (em == null)
System.out.println("Vp em is null");
return (VpInfo)em.createQuery(
"from VpInfo v where v.appGroup = :appGroup").setParameter("appGroup", appGroup).getSingleResult();
}
}
================================
persistence.xml
<persistence-unit name="VealMonitorDB">
<jta-data-source>java:/DefaultDS</jta-data-source>
<!--
-->
<!-- -->
</persistence-unit>
<persistence-unit name="VPInfoDB">
<jta-data-source>java:/DefaultDS</jta-data-source>
<!--
-->
<!-- -->
</persistence-unit>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129486#4129486
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129486
18 years, 2 months
[JBoss Seam] - Re: Named conversation and new instance redirected to Home?
by enda
Hi Erik,
I would have two note for your solution.
1.
I do not know if Seam 2.1.0A1 undeprecated id in @Begin.
As you have
| @Begin(join = true, id = #{facesContext.externalContext.requestParameterMap.forsendelseId}")
|
There were some issues why it got deprecated and note from Gavin King was to use pages.xml for it. So if it is undeprecated then it is ok.
2.
| <core:manager conversation-id-parameter="forsendelseId" />
|
this will work. But if you have let say two completely different entity Types in your conversational context and they have the same id. You would actually merge them.
What would help is this:
| <h:dataTable id="forsendelser" value="#{forsendelser}" var="fors">
| <h:column>
| <s:link action="#{forsendelseaction.someactionmethod}">
| <f:param name="forsendelseId" value="#{fors.className}#{fors.id}" />
| #{fors.id}
| </s:link>
| </h:column>
| </h:dataTable>
|
here you would know which entityType is in conversation context.
Please let me know what do think about that.
Tomas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129478#4129478
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129478
18 years, 2 months