Allow me to answer my own quetions:

1) rather removing the <mapping> line from hibernate.cfg.xml, I had to
replace it with

     <mapping class="flex.samples.contact.Contact"/>

2) had to ensure the the named query "all" was defined at the top of the
Contact class i.e.


@NamedQuery(name="all", query="From Contact")

That pretty much did it - required no other changes to the
data-management-config.xml other than specifying
HibernateAnnotationsAssembler...

And for any one out there who may care, the following is the full
Contact.java class modified to use annotations:

package flex.samples.contact;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name="contact")
@NamedQuery(name="all", query="From Contact")
public class Contact {

     private int contactId;

     private String firstName;
     private String lastName;
     private String address;
     private String city;
     private String state;
     private String zip;
     private String country;
     private String email;
     private String phone;
     private String notes;

     @Id
     @GeneratedValue(strategy=GenerationType.AUTO)
     @Column(name="contact_id")
     public int getContactId() {
         return contactId;
     }
     public void setContactId(int contactId) {
         this.contactId = contactId;
     }

     public String getAddress() {
         return address;
     }
     public void setAddress(String address) {
         this.address = address;
     }
     public String getCity() {
         return city;
     }
     public void setCity(String city) {
         this.city = city;
     }

     public String getCountry() {
         return country;
     }
     public void setCountry(String country) {
         this.country = country;
     }
     public String getEmail() {
         return email;
     }
     public void setEmail(String email) {
         this.email = email;
     }


     @Column(name="first_name")
     public String getFirstName() {
         return firstName;
     }
     public void setFirstName(String firstName) {
         this.firstName = firstName;
     }


     @Column(name="last_name")
     public String getLastName() {
         return lastName;
     }
     public void setLastName(String lastName) {
         this.lastName = lastName;
     }
     public String getNotes() {
         return notes;
     }
     public void setNotes(String notes) {
         this.notes = notes;
     }
     public String getPhone() {
         return phone;
     }
     public void setPhone(String phone) {
         this.phone = phone;
     }
     public String getState() {
         return state;
     }
     public void setState(String state) {
         this.state = state;
     }
     public String getZip() {
         return zip;
     }
     public void setZip(String zip) {
         this.zip = zip;
     }


}

--- In flexcoders@yahoogroups.com, "gordon_greg" <[EMAIL PROTECTED]> wrote:
>
> Hi.
>
> I do indeed see that the
> flex.data.assembler.HibernateAnnotationsAssembler is provided in the
> flex.data.jar file distributed with LCDS 2.6b2.
>
> However, I have no idea how to get it working:
>
> I tried modifying the simple Contact demo using Hibernate that comes
> as a sample for LCDS 2.6 to use annotations, and then I commented out
> the following line in hibernate.cfg.xml:
>
>
>    <mapping resource="flex/samples/contact/Contact.hbm.xml"/>
>
> Then I changed the data-management-config.xml entry for
>
>    <destination id="hibernate-contact">
>
>
> To use
>
>   <source>flex.data.assemblers.HibernateAnnotationsAssembler</source>
>
> And I assumed this was all I would have to change to get this working.
>
> However, when I attempt to start up the server, I simply get errors
i.e.:
>
> [Flex] [ERROR] MessageBroker failed to start:
> flex.data.adapters.AdapterException: No Hibernate mapping was found
> for entity name 'flex.samples.contact.Contact' configured in
> destination 'hibernate-contact'. Please verify that your destination
> configuration specifies a valid <hibernate-entity/>, or that the
> destination id references a valid entity.
>  at flex.data.assemblers.HibernateType.start(HibernateType.java:195)
>  at
>
flex.data.assemblers.HibernateAssembler.start(HibernateAssembler.java:20\
5)
> ....
>
>
> I was not able to locate the source code for the
> HibernateAnnotationsAssembler anywhere, nor can I find any reference
> to this file in any other forum, site, document, etc.
>
> I did look at the decompiled code, and I can see that it simply
> extends the Hibernate assebmler, and over-writes the
> createHiberanteConfigureation method, but again, I just don't know
> what the magic is to get this thing configured and reading in
> annotation information.
>
> Any small, simple example would be just lovely.
>
> Thanks!
>
> Greg Gordon
>
>
>
>
> --- In flexcoders@yahoogroups.com, "Jeff Vroom" jvroom@ wrote:
> >
> > The 2.6 beta (on labs.adobe.com) has annotations support built in -
you
> > have to use the HibernateAnnotationsAssembler instead of the
> > HibernateAssembler in your data-management-config.xml.  It is not
too
> > hard to add to 2.5.1 if you need it there too... there are some new
jar
> > files you need to add and you need to override a method in the
> > HibernateAssembler to specify a different class to bootstrap the
> > configuration.   The source for this is also in the 2.6 beta if you
want
> > to check it out.
> >
> >
> >
> > Jeff
> >
> >
> >
> > ________________________________
> >
> > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On
> > Behalf Of Mathieu Fernandez
> > Sent: Wednesday, April 30, 2008 3:24 AM
> > To: flexcoders@yahoogroups.com
> > Subject: [flexcoders] Use hibernate annotations with LiveCycle Data
> > Services
> >
> >
> >
> > Hello,
> > I'm trying to use hibernate annotations with LiveCycle Data
Services.
> > My problem is when I launch my server I have this error :
> > "An annotationConfiguration instance is required to use <mapping
> > class="...">"
> > So I would like to know how enabling annotation configuration?
> > Thanks
> >
>

Reply via email to