[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-02 Thread bravefencer
so here is my code:

@Stateful
  | @Scope(ScopeType.SESSION)
  | @Name(SessionObjektAuswahl)
  | public class SessionObjektAuswahl implements ISessionObjektAuswahl{
  | 
  | 
  | @DataModel
  | private ListKioskPC kioskPCListe;
  | 
  | @DataModelSelection
  | @Out(required=false)
  | private KioskPC kiosk;
  | 
  | @Out(required=false)
  | private KioskPC kiosk2;
  | 
  | @In(required=false)
  | private String DBname;
  | 
  | 
  | 
  | 
  |  EntityManager em;
  | 
  | @Logger
  | private Log log;
  | 
  | private boolean toMitarbeiterAuswahl;
  | 
  | @In(required=false)
  | @Out(required=false)
  | private boolean toAnwesenheit;
  | 
  | 
  | @Create
  | @Factory(kioskPCListe)
  | public String retrieveAllKioskPCEintraege() {
  | 
  | initialize();   
  | KioskPCAction kioskAction = new KioskPCAction();
  | kioskPCListe = kioskAction.getAllFromDB(em);
  | 
  | return null;
  | }
  | 
  | private void select(){
  | 
  | }
  | 
  | 
  | 
  | private void clearSelected(){
  | kiosk = null;
  | 
  | }
  | 
  | @Remove @Destroy
  | public void destroy() {
  | // TODO Auto-generated method stub
  | 
  | }
  | 
  | public void remove() {
  | // TODO Auto-generated method stub
  | 
  | }
  | 
  | 
  | @Override
  | public void initialize() {
  | 
  | em = (EntityManager)Component.getInstance(QMoDISZDB);
  | 
  | 
  | //setLanguage();
  | }
  | 
  | 
  | 
  | private void setLanguage(){
  | this.titleValueObjektauswahl = Parser.read(
  | FormObjektAuswahl.titel, sprache);
  | this.buttonValueAlleObjekte = Parser.read(
  | FormObjektAuswahl.btAlleAuswaehlen, sprache);
  | }
  | 
  | 
  | @Override
  | public String navigate(String id) {
  | 
  | if(kiosk!=null){
  | log.info(kiosk.getObjektKostenstelle());
  | }
  | 
  | 
  | if(toMitarbeiterAuswahl) {
  | 
  | toMitarbeiterAuswahl = false;
  | 
  | if(id.equals(startseite)){
  | kiosk2=kiosk;
  | return mitarbeiterAuswahl;
  | }
  | 
  | else if(id.equals(clear)){
  | kiosk2=null;
  | return nachrichtenUebersicht;
  | }
  | }
  | 
  | else if (toAnwesenheit){
  | toAnwesenheit = false;
  | if (id.equals(startseite)){
  | kiosk2=kiosk;
  | return anwesenheit;
  | }else if(id.equals(clear)) {
  | kiosk2=null;
  | clearSelected();
  | return startseite;
  | }
  | }
  | 
  | //  else if (id.equals(anwesenheit)){
  | //  toAnwesenheit = true;
  | //  return objektAuswahl;
  | //  }
  | else if(id.equals(nachrichtErstellen))
  | {
  | toMitarbeiterAuswahl=true;
  | return objektAuswahl;
  | }
  | 
  | 
  | else if(id.equals(startseite)){
  | kiosk2=kiosk;
  | return startseite;
  | }
  | else if(id.equals(clear)) {
  | kiosk2=null;
  | clearSelected();
  | return startseite;
  | 
  | }
  | 
  |  return null;
  | 
  | 
  | }
  | 
  | }


components.xml:

core:managed-persistence-context name=QMoDISZDB
  | auto-create=true 
persistence-unit-jndi-name=java:/DBzweiEntityManagerFactory /


persistence.xml:

  | persistence-unit name=DBzwei
  |   providerorg.hibernate.ejb.HibernatePersistence/provider
  |  jta-data-sourcejava:/DBzweisource/jta-data-source
  |
  |   properties
  |  property name=hibernate.hbm2ddl.auto value=none/
  |  property name=hibernate.show_sql value=true/
  |  !-- These are the 

[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-02 Thread bravefencer
i have found the failure. 

The SMPC Scope-Type ist Conversational, but i'am using Scope-Type SESSION for 
my Session Beans. 
If i switch to Conversational Scope-Type , then it works. 
Hope the Applications Behaviour will  be achieved..

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090527#4090527

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090527
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread monkeyden
Have you tried the unitName attribute?

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090330#4090330

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090330
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
hello,

yes i tried. but i got an exception:

Field javax.persistence.EntityManager 
QMoDIS.backend.BussinessTier.session.SessionObjektAuswahl.em @PersistenceUnit 
in error: EMPTY STRING unitName and there is more than one scoped persistence 
unit


That's the problem, because i have more than one persistence-Unit.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090334#4090334

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090334
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
i want to extend the persistence context for all possible persistence-contexts, 
that may be injected.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090335#4090335

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090335
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread monkeyden
What value did you provide for unitName?  Was it a value from your 
persistence.xml file?

persistence-unit name=someDB
  | ...
  | /persistence-unit

@PersistenceContext(unitName=someDB) 

I think this is the way it's done anyway.  Personally, I use SMPC.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090362#4090362

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090362
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread [EMAIL PROTECTED]
An SMPC is equivalent to an extended persistence context for conversationally 
scoped components.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090366#4090366

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090366
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
i have more than one persistence unit defined in persistence.xml, because i'am 
using more than one database.
But for all possible units i have defined in the persistence.xml i must have an 
extended persistence context. 


View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090399#4090399

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090399
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
is there a way to define the extension of the persistence contexts directly in 
the persistence.xml instead of annotating this behaviour at the entitymanager 
definition?

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090401#4090401

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090401
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
i used SMPC(for example): 

core:managed-persistence-context name=myManagername
  |   auto-create=true
  |   
persistence-unit-jndi-name=java:/myjndiname
  | /core:managed-persistence-context

but the context is not extended, because 
in the code i get the ref to the Entitymanger i described further, but the 
Dataselection Model will not work in my stateful session beans, so it's not 
extended.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090403#4090403

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090403
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread monkeyden
Seam bijection depends on variable name.  Try this:

@In(create=true)
  | private EntityManager myManagername;

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090404#4090404

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090404
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
the problem is that the name of the entitymanager will be determined at 
runtime. so i can't put the static variable name before runtime in my code.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090405#4090405

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090405
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread monkeyden
Not sure why it needs to be determined at runtime but have you tried:
EntityManager em = (EntityManager)Component.getInstance(someRuntimeString, 
true);

???  

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090409#4090409

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090409
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
yes. look at my first posting ;)
but if i inititialize the Entitymanager on that way(in some SFSB) the 
DataSelection Model will not work properly. It works only if in Annotate the 
Entitymanager Variable with @PersistenceContext(unit-namemyunitname, 
type=PersistenceContextType.EXTENDED). 

But then i must hardcode a unit-name, and thats the problem.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090412#4090412

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090412
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
it's needed at runtime, because, every EntityManager has a binding to a 
database and which Database will be used, is decided at runtime.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090414#4090414

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090414
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread monkeyden
You can't inject something if you don't know the name.  If you have to 
determine the name at runtime, you'll have to do it inline.

core:managed-persistence-context name=myManagername auto-create=true 
persistence-unit-jndi-name=java:/myjndiname
  | /core:managed-persistence-context


public void someMethod(){
  | String emName = getEMName();
  | EntityManager em = (EntityManager)Component.getInstance(emName, true);  
  | ...
  | //do some work
  | }
  | 



View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090417#4090417

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090417
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
hmm,

i define the Entitymanager on that way:

EntityManager em = (EntityManager)Component.getInstance(someRuntimeString);

Without the second Parameter set on true. maybe thats the problem ? 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090416#4090416

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090416
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread monkeyden
Actually, if auto-create=true, you don't need the true parameter, but 
getEMName() would return the String myManagername or any other EM name you 
have configured in components.xml.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090418#4090418

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090418
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
yes. thats exact what i'am doing, but with more than on EntityManager defined 
in the corresponding xml files, and it works. Thats not the problem. 
The Problem that the Persistence context seems not to be extended. I get some 
data sets over the EntityManager, show them in a datatable, use Dataselection 
Model, but i don't get the correct reference to the selected data set in the 
table. 

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090422#4090422

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090422
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread [EMAIL PROTECTED]
I really doubt your datamodelselection has anything to do with whether the 
persistence context is extended or not.  Why don't you actually post your code 
and the problem you have rather than plucking solutions out of thin air?

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090426#4090426

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090426
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JBoss Seam] - Re: How to Extend Persistence Context Programatically

2007-10-01 Thread bravefencer
but if i extend the context with @PersistenceContext(... 
type=PersistenceContextType.EXTENDED) Annotation, the Dataselectionmodel works 
:)
So i think, its because the Context is not extend, if i do it the other way. 

Anyway, i will post my code tomorrow. It would be very nice if i can get a 
Solution.


View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=4090431#4090431

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4090431
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user