Hi Davis,

I agree with you, I don’t think you have to configure
data-management-config.xml to use only messaging and I don’t think you have
to use [Managed] in your Clienti.as too.

About the lazy problem, the best approach to me is to pass to flex a plain
Class that contains only the data that you will use in your view. It won't
be the same as your Entity on JAVA.

Another way is to use joins in your query to initialize relationships,
setting null all other unnecessary properties. But this will take some of
your time to implement, and you will have to use reflection to build
something useful.

Henrique.


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Devis
Sent: sexta-feira, 18 de maio de 2007 08:28
To: flexdev
Subject: [flexdev] Re: detached entity .LazyInitializationException?
urgently


Hi  Henrique,
i'm not using in my application DataService but only jms/queue, then i
haven't configure
data-management. (JBoss/Hibernate EntityManager)

This my scenario:
Java side
1)My Entity Class
@Entity
@Table(name = "clienti")
....
    @Column(name = "nome", nullable = false)
    private String nome;

    @Column(name = "cognome", nullable = false)
    private String cognome;

    @Column(name = "indirizzo")
    private String indirizzo;


    @JoinColumn(name = "lingua", referencedColumnName = "idlingua")
    @ManyToOne()
    private Lingue lingua;
.....
My Lingue class Entity
    @Id
    @Column(name = "idlingua", nullable = false)
    private Integer idlingua;

    @Column(name = "stringa", nullable = false)
    private String stringa;

    @Column(name = "immagine")
    private Integer immagine;

    @OneToMany(mappedBy = "lingua")
    private Collection<Users> usersCollection;

    @OneToMany(mappedBy = "langsubtitles")
    private Collection<Vhs> vhsCollection;



My Session Facade
//@Statless
@Stateful
public class ClientiFacade implements ClientiFacadeLocal {


    @PersistenceContext(type=PersistenceContextType.EXTENDED)
    private EntityManager em;


    /** Creates a new instance of ClientiFacade */
    public ClientiFacade() {
    }

    public void create(Clienti clienti) {
        em.persist(clienti);
    }

    public void edit(Clienti clienti) {
        em.merge(clienti);
    }

    public void destroy(Clienti clienti) {
        em.merge(clienti);
        em.remove(clienti);
    }

    public Clienti find(Object pk) {
        return (Clienti) em.find(Clienti.class, pk);
    }

    public List findAll() {
        List lista = null;
        try {
            UserTransaction tx = (UserTransaction) new
InitialContext().lookup("UserTransaction");
            tx.begin();
            lista=em.createQuery("select object(o) from Clienti as
o").getResultList();
            tx.commit();
        } catch (Exception ex) {

            ex.printStackTrace();
        }
        finally {
            em.clear();
        }
        return lista;
    }

    public Clienti findByName(String nome) {

        Clienti _cli
=(Clienti)em.createNamedQuery("Clienti.findByNome").setParameter("nome",nome
).getSingleResult();

        return _cli;
    }

}

My Java Mdb


      public void onMessage(Message message) {
      try {


                Clienti _msg = (Clienti)
((ObjectMessage)message).getObject();
                System.out.println("MessageBean onMessage"
+_msg.getNome());
                ClientiFacadeLocal
facade=(ClientiFacadeLocal)CachingServiceLocator.getInstance().getLocalHome(
ClientiFacade.class);
                Clienti _cli=facade.findByName(_msg.getNome());
                System.out.println("onMessage toString
"+_cli.toString());
                .....
                push into a queue my _cli object ..... my
vde_response_login quee



Flex Side

<!-- Code jms Risposta login utente-->
<destination id="vde_response_login">
    <properties>
<server>
<durable>false</durable>
<durable-store-manager>
flex.messaging.durability.FileStoreManager
</durable-store-manager>
</server>
 <jms>
 <destination-type>Topic</destination-type>
 <message-type>javax.jms.ObjectMessage</message-type>
 <connection-factory>ConnectionFactory</connection-factory>
 <destination-jndi-name>topic/VdeResponseLoginQueue</destination-jndi-
name>
 <destination-name>VdeResponseLoginQueue</destination-name>
 <delivery-mode>NON_PERSISTENT</delivery-mode>
 <message-priority>DEFAULT_PRIORITY</message-priority>
 <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
 <transacted-sessions>false</transacted-sessions>
    <!-- (Optional) JNDI environment. Use when using JMS on a remote
JNDI server. -->
    <initial-context-environment>
      <property>
        <name>Context.URL_PKG_PREFIXES</name>
        <value>org.jboss.naming:org.jnp.interfaces</value>
      </property>
      <property>
        <name>Context.PROVIDER_URL</name>
        <value>jnp://127.0.0.1:1099</value>
      </property>
       <property>
        <name>Context.INITIAL_CONTEXT_FACTORY</name>
        <value>org.jnp.interfaces.NamingContextFactory</value>
      </property>
   </initial-context-environment>

     </jms>
    </properties>
           <channels>

            <channel ref="my-rtmp"/>

        </channels>

<adapter ref="jms"/>
</destination>




MY MXML

                public function RequestLogin():void

                {

                        Subscribe();
                        var message:AsyncMessage = new AsyncMessage();
                        var obj:Clienti=new Clienti();
                        obj.nome=tx_nome.text;
                        message.body =obj;
                        message.headers=new Array();
                        message.headers["JMSCorrelationID"]=obj.nome;
                        request_login.send(message);
                }

              private function messageLoginHandler(event:
MessageEvent):void {
               _cli=event.message.body;
                trace('_Debug Devis '+event.message.body);
             }


                private function faultHandler(event:MessageFaultEvent):void
{
                Alert.show(event.faultString + "Errore");
            }

            private function onResult(event:ResultEvent):void {
                 _cli=event.result as Clienti;
            }



        [Bindable]
        private var _cli:Clienti;



    <mx:Producer id="request_login" destination="vde_request_login"
         fault="faultHandler(event)"/>



    <mx:Consumer id="response_login" destination="vde_response_login"
         message="messageLoginHandler(event)"
         fault="faultHandler(event)"/>





Thanks have you some idea? but in this scenario i think i don't
configure data-management right?
Devis















On May 18, 3:33 am, "Henrique" <[EMAIL PROTECTED]> wrote:
> Hi Davis,
>
> Can you write down your data-management-config.xml. Are you mapping your
> associations on this file?
>
> Henrique
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
>
> Of Devis
> Sent: quinta-feira, 17 de maio de 2007 13:09
> To: flexdev
> Subject: [flexdev] Re: detached entity .LazyInitializationException?
> urgently
>
> Sorry to all, if i post in english i'm italian.
> Hi to all,
> i'm disperate with my prblem.
> I have this scenario:
> 1)I'm using jms/mdb ejb3 with jboss 4.2
> 2)I'm using FDS with Consumer/Producer comp.
>
> My mdb
>
> public void onMessage(Message message) {
> try {
>
> Clienti _msg = (Clienti)
> ((ObjectMessage)message).getObject();
> System.out.println("MessageBean onMessage"
> +_msg.getNome());
> ClientiFacadeRemote
>
facade=(ClientiFacadeRemote)CachingServiceLocator.getInstance().getRemoteHom
> e(Cl
> \
> ientiFacade.class);
> Clienti _cli=facade.findByName(_msg.getNome());
> System.out.println("onMessage toString "+_cli.toString());
> Clienti _cl = new Clienti(_cli);
> //to queue
> Send(_cl);
>
> this my ClientFacade
> @Stateless
> //@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
> public class ClientiFacade implements ClientiFacadeRemote {
>
> @PersistenceContext()
>
> private EntityManager em;
> //private EntityManagerFactory entityManagerFactory =
> Persistence.createEntityManagerFactory("NuovVdeUN");
> //EntityManager em = entityManagerFactory.createEntityManager();
>
> /** Creates a new instance of ClientiFacade */
> public ClientiFacade() {
> }
>
> public void create(Clienti clienti) {
> em.persist(clienti);
> }
>
> public void edit(Clienti clienti) {
> em.merge(clienti);
> }
>
> public void destroy(Clienti clienti) {
> em.merge(clienti);
> em.remove(clienti);
> }
>
> public Clienti find(Object pk) {
> return (Clienti) em.find(Clienti.class, pk);
> }
>
> public List findAll() {
>
> return em.createQuery("select object(o) from Clienti as
> o").getResultList();
> }
>
> public Clienti findByName(String nome) {
> Clienti _cli
>
=(Clienti)em.createNamedQuery("Clienti.findByNome").setParameter("nome",nome
> ).ge
> \
> tSingleResult();
> em.clear();
> return _cli;
> }
>
> }
>
> vde.com.ejb.vo.Clienti is my EJB3 Entity with some Lazy collection
> ActionScript DTO
> import mx.collections.ArrayCollection;
> [Managed]
> [RemoteClass (alias="vde.com.ejb.vo.Clienti")]
> public class Clienti
> ......
>
> I have made 30 test/example with Persistence.Extended @Steful etc.
> my last test using EntityManager.clear for detached entity...
> but my ActionScript dto always try to initialize all my collection
> lazy and throws my exception "Lazy and
> flex.messaging.io.ArrayCollection.<init>(ArrayCollection.java:44
> ........
>
> Why if my backend doesn't initiliaze some Lazy Collection why my Flex
> wonts that all lazy collection are initilaze? Pls it's a week that i
> have this problem.
> I have read inwww.graniteds.org(oper source alternative) .."With
> GDS, you can keep those uninitialized references with lazy"... but how
> i can doing this with Fds.
> I have also download Live Cycle data beta but i have the same problem.
> Can you help me pls?
> Ciao e grazie
> Devis




--~--~---------~--~----~------------~-------~--~----~
Você recebeu esta mensagem porque está inscrito na lista "flexdev"
Para enviar uma mensagem, envie um e-mail para [email protected]
Para sair da lista, envie um email em branco para [EMAIL PROTECTED]
Mais opções estão disponíveis em http://groups.google.com/group/flexdev
-~----------~----~----~----~------~----~------~--~---

Responder a