7 Replies Latest reply on Oct 17, 2006 12:46 PM by busitech

    Are Hibernate Annotations supported?

      Does FDS support Hibernate annotations? Will the use of hibernate annotations create any problems?

        • 1. Re: Are Hibernate Annotations supported?
          seth_hodgson Level 1
          Hi HC,

          I haven't had a chance to play with Hibernate's new annotation support which isn't final yet, but the FDS Hibernate assembler doesn't have any direct dependence on where your entity mappings are defined. It needs the location of your core Hibernate config file and that's it; all other info it uses is obtained from a corresponding Hibernate Configuration object. So my guess is that using annotations for your mappings should "just work" ;)

          When using the Hibernate assembler you still need to define association relationships between your data service destinations. These are not automatically created based on existing Hibernate entity mappings.

          Post back if you get a chance to try this out. I'll add it to my queue of things to investigate.

          • 2. Are Hibernate Annotations supported?
            Unfortunately the session is builded by using an org.hibernate.cfg.AnnotationConfiguration but the HibernateAssembler only uses org.hibernate.cfg.Configuration.
            So I extended the HibernateAssembler to use a AnnotationConfiguration and also changed the source of the destination to my Assembler in the 'data-management-config.xml'. The hibernate.cfg.xml and both Employee.java and Company.java of the hibernate fds-sample 'crm' (tested with another tool) are adapted to hibernate 3 annotations. but all i got is the error message:

            faultDetail=Channel.Connect.Failled error null

            Google and Adobe told me this is an hibernate.cfg.xml-error but i do not believe so because using the same files by implementing a simple testcase is working and connecting successfully.
            • 3. Re: Are Hibernate Annotations supported?
              jvroom Level 1
              You are charting new ground using hibernate annotations but it sounds like your approach is the right one. The error you are getting now is a general one which happens when an uncaught exception occurs on the server. The best way to diagnose that is to turn on Debug logging on the server (edit WEB-INF/flex/services-config.xml, search for level= and change that attribute to Debug. Make sure that your <patterns> tags below have both Message.* and DataService.*. You should see the stack trace and detailed error on what caused the exception and that would help us determine what is going on. I'd be happy to help get this to work - this is an important use case.
              • 4. Re: Are Hibernate Annotations supported?
                seth_hodgson Level 1
                Hi Pete,

                That error indicates that your client app is not able to establish a connection to the server. I'd recommend using <mx:TraceTarget/> to enable client side debug output to flashlog.txt and take a look there to see which channel is failing to connect and what the underlying root cause is.

                Common reasons for this are invalid or out of date channel endpoint URIs or a {context.root} token in a channel URI not being replaced at compile time with the true value (use the -compiler.context-root mxmlc option).

                If your simple test case is working, once you've got the connection problem between the client and server sorted out you should be in good shape.

                • 5. Re: Are Hibernate Annotations supported?
                  busitech Level 1
                  We have the JBoss implementation of EJB 3.0 working with Flex. The JBoss implementation of EJB 3.0 is really hibernate annotations... In this configuration, Flex does not need to talk directly to Hibernate, and we have the full power of the new EJB 3.0 Annotations (beyond the support and features provided in the HibernateAdapter). Our Assemblers use JNDI to access session beans which work with the entity beans.

                  One huge problem with Flex however is that due to the relationships between objects in the ORM, combined with FDS's desire to access each public property, the LazyInitializationException rears it's ugly head every time a lazy association property is traversed.

                  We desparately need FDS to recognize the proxy object for what it is - a land mine waiting to go off should the property be touched once outside the transaction which has already been closed (inside the serialization process to AMF or RTMP).

                  We currently intercept the calls to null out proxy objects after the transaction is closed but before FDS has a chance to set off the land mine, and this works for the most part. However, not being able to take advantage of lazy initialization causes a lot more data to be sent back and forth.

                  I would really encourage a change of FDS serialization code to watch for the common objects used to represent the existance of a proxy within the common ORM solutions, and jump over them when building the object graph. It's an essential part of an application in an ORM environment.
                  • 6. Re: Are Hibernate Annotations supported?
                    Please keep this thread going!! This use case is central to our companies strategy and the documentation / material out there for "the rest of us" is non-existant.

                    Pete / Seth / jvroom, have you got any further in your research on this? Would you be willing to elaborate on findings? I would very much like to pursue getting this to work.

                    Stupid question #1: When did you get the source for the HibernateAssembler class? I cannot seem to locate it.

                    busitech, I am not sure I follow you completely. If I understand correctly, your flex app points to the destination which is using your own custom assembler and loads the session beans (via JNDI lookup) essentially as delegates to the entity beans in place of the actual entity beans? Would you be willing to share some of your insights as to how you got this working? Any documentation / reference material would be helpful.

                    • 7. Re: Are Hibernate Annotations supported?
                      busitech Level 1
                      This thread was started by hchafi to discuss using the HibernateAdapter to reach the goal of using Hibernate Annotations.

                      I introduced a different approach to achieve the same goal by AVOIDING the HibernateAdapter (becuase it only supports CRUD methods and requires 100% of your business logic to be written in actionscript on the client).

                      bjk0002, I am not sure which method you are truly interested in. For my approach, the documentation is out there. I would suggest your starting point be reading the JavaDoc supplied in your FDS install directory for the flex.data.assemblers.AbstractAssembler class.

                      Actually, HibernateAssember is also an example of my approach because it is a custom assembler extending the above class (AbstactAssembler).

                      The source for HibernateAssembler is in C:\fds2\resources\samples\assemblers