Re: [jboss-user] [EJB 3.0] - Multiple Persistence Units with the same entities
by Andrig Miller
Andrig Miller [http://community.jboss.org/people/andy.miller%40jboss.com] replied to the discussion
"Multiple Persistence Units with the same entities"
To view the discussion, visit: http://community.jboss.org/message/536638#536638
--------------------------------------------------------------
> jaikiran pai wrote:
>
> > Andrig Miller wrote:
> >
> >
> > So, I created two persistence units in my persistence.xml, with two different sets of Hibernate properties, pointing at the same database, and let it default to scanning for the Entities in my jar.
> >
> I missed this earlier. So effectively, you are sharing the same entities between multiple entity managers. Do those entity managers really "share" those entities in your application? For example, if you try to access an entity which is shared (i.e. you access the entity using both the entity managers) then you will end up running into issues because each of these entity managers, that come from different entity manager factories, will (possibly) hold a different state.
Well, I don't use the same entities from two different entity manager's at the same time, or within the same transaction. One entity manager is used to do an initial data load of a bunch of reference data into the database, and the other entity manager is used for transaction processing against that data. The two processes are independent, and the OLTP processing cannot occur until after the batch process has completed anyway. So, there is no overlap, where the same entity would be used in two entity managers at the same time, and have different state.
Before even doing this, I thought through that, but is this something that is compliant with the spec. All the reading I have done, only vaguely hint at having the same entities into two different persistence units, and everything I have read basically says that a persistence unit is tied to one data source (maybe implying that multiple persistence units should have "unique" data sources).
So, while it works now, and based on the functions involved, there is no overlap, will this continue to work in the future? If its not supported by the spec, then I have a reasonable expectation that this might break in the future.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536638#536638]
Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [jBPM] - Async Fork Transaction Issues
by Maciej Swiderski
Maciej Swiderski [http://community.jboss.org/people/swiderski.maciej] replied to the discussion
"Async Fork Transaction Issues"
To view the discussion, visit: http://community.jboss.org/message/536636#536636
--------------------------------------------------------------
Hi Rachel,
took me some time to look deeper into your issue but finally I did it. Here are some explanations:
> 2) When run as a unit test, each node only prints its name once, and the test passes.
This is due to not enough time for job executors to finish their job, I mean that your main thread (junit) will kill all child threads as soon it will go through the loop. Just put a sleep on your main class and you should get all print outs from your custom nodes.
> 1) When run as a Java application , the following exception is thrown:
> *
> *
> *org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.pvm.internal.model.ExecutionImpl#7]*
I could reproduce that only when I manually executed job at the same time job executors were running. Moreover, I did deploy it to db and then run it from console and it worked fine. Did you try to run it from console?!
HTH
Maciej
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536636#536636]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [EJB 3.0] - Multiple Persistence Units with the same entities
by jaikiran pai
jaikiran pai [http://community.jboss.org/people/jaikiran] replied to the discussion
"Multiple Persistence Units with the same entities"
To view the discussion, visit: http://community.jboss.org/message/536631#536631
--------------------------------------------------------------
> Andrig Miller wrote:
>
> In the batch processing methods I use the entity manager that is configured for batch processing, and in the other methods I use the one configured for OLTP processing.
>
> This is all working, but when I was reading various sources for whether this "should" work, it wasn't clear.
>
> So, while it does work, what I am wondering, is this spec compliant, or is this just dumb, blind luck that it works?
It's definitely +not+ luck :) I don't see anything wrong in what you are doing.
One thing that you might want to keep note is to make sure that you don't end up using both those entity managers in the same transaction - in which case you would be enrolling 2 transaction aware resources (the datasource corresponding to the entity managers) in one transaction. You would then require XA datasources for such cases.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536631#536631]
Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [EJB 3.0 Development] - ejb3_1 and its relation with ejb3 bom
by jaikiran pai
jaikiran pai [http://community.jboss.org/people/jaikiran] replied to the discussion
"ejb3_1 and its relation with ejb3 bom"
To view the discussion, visit: http://community.jboss.org/message/536626#536626
--------------------------------------------------------------
> Andrew Rubinger wrote:
>
>
> If the BOM is the parent of the ejb3_1 module, then the ejb3_1 module will have the correct exported dependencies. Now something else, project X, makes a depedendency upon ejb3_1. Any "exclusion"s defined by the BOM will be *ignored*. This is because Project X doesn't have the BOM in its hierarchy. The way around this is to declare in Project X a dependency twice upon ejb3_1; once in "dependencies", once in "dependencyManagement" (with scope import).
>
> S,
> ALR
The project X that I was considering was AS. So we would have something like:
ejb3_1 module pom.xml:
<parent>
<artifactId>bom-as6</artifactId>
<version>0.1.3</version>
</parent>
<artifactId>jboss-ejb3_1</artifactId>
bom-as6 pom.xml:
<artifactId>bom-as6</artifactId>
<dependencyManagement>
<dependency>
<artifactId>jboss-ejb3-core</artifactId>
<version>1.3.2</version>
</dependency>
<!-- rest of the dep management -->
</dependencyManagement>
JBoss AS component-matrix pom.xml (or some module which "imports" the bom)
<dependencyManagement>
<dependency>
<artifactId>bom-as6</artifactId>
<scope>import</scope>
</dependency>
</dependencyManagement>
The AS/ejb3 module pom.xml would add "dependency" on *ejb3_1*
<dependencies>
<dependency>
<artifactId>jboss-ejb3_1</artifactId>
<!-- We don't specify any version here, it will be picked up from bom -->
</dependency>
</dependencies>
But like I said in my previous post, making bom-as6 the parent of ejb3_1 may not work out.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536626#536626]
Start a new discussion in EJB 3.0 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years