Issue with airline demo and hibernate

Darin Buck <[email protected]> Wed, 14 Sep 2005 19:47:27 -0400
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
Using:
middlegen-2.1
java 1.4.2_08

I changed the sample app to use hibernate instead of cmp20, which
results in a broken build:

compile-adapter:
    [javac] Compiling 1 source file to
/home/gcg/middlegen-2.1/samples/build/classes
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:21:
cannot resolve symbol
    [javac] symbol  : method setReservationId (java.lang.Integer)
    [javac] location: class airline.hibernate.Reservation
    [javac]         =20
reservationPersistence.setReservationId(reservationForm.getReservationId())=
;
    [javac]                                 ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:22:
cannot resolve symbol
    [javac] symbol  : method setPersonIdFk (java.lang.Integer)
    [javac] location: class airline.hibernate.Reservation
    [javac]           =20
reservationPersistence.setPersonIdFk(reservationForm.getPersonIdFk());
    [javac]                                   ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:23:
cannot resolve symbol
    [javac] symbol  : method setFlightIdFk (java.lang.Integer)
    [javac] location: class airline.hibernate.Reservation
    [javac]           =20
reservationPersistence.setFlightIdFk(reservationForm.getFlightIdFk());
    [javac]                                   ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:36:
cannot resolve symbol
    [javac] symbol  : method getReservationId ()
    [javac] location: class airline.hibernate.Reservation
    [javac]         =20
reservationForm.setReservationId(reservationPersistence.getReservationId())=
;
    [javac]                                                                =
  ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:37:
cannot resolve symbol
    [javac] symbol  : method getPersonIdFk ()
    [javac] location: class airline.hibernate.Reservation
    [javac]           =20
reservationForm.setPersonIdFk(reservationPersistence.getPersonIdFk());
    [javac]                                                                =
 ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:38:
cannot resolve symbol
    [javac] symbol  : method getFlightIdFk ()
    [javac] location: class airline.hibernate.Reservation
    [javac]           =20
reservationForm.setFlightIdFk(reservationPersistence.getFlightIdFk());
    [javac]                                                                =
 ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:39:
setRegistrationUtc(java.sql.Timestamp) in
airline.web.struts.ReservationForm cannot be applied to
(java.util.Date)
    [javac]                     =20
reservationForm.setRegistrationUtc(reservationPersistence.getRegistrationUt=
c());
    [javac]                                      ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:67:
setDepartureUtc(java.sql.Timestamp) in airline.web.struts.FlightForm
cannot be applied to (java.util.Date)
    [javac]                               =20
flightForm.setDepartureUtc(flightPersistence.getDepartureUtc());
    [javac]                                           ^
    [javac] /home/gcg/middlegen-2.1/samples/build/gen-src/airline/adapter/T=
ranslatorUtil.java:68:
setArrivalUtc(java.sql.Timestamp) in airline.web.struts.FlightForm
cannot be applied to (java.util.Date)
    [javac]                               =20
flightForm.setArrivalUtc(flightPersistence.getArrivalUtc());
    [javac]                                           ^
    [javac] 9 errors


Looking at the first error in the code, it appears that the generated
value object isn't using the generated composite key object:

here is what is generated:

from middlegen-2.1/samples/build/gen-src/airline/adapter/TranslatorUtil.jav=
a:

   /**
    * Copy data from a airline.web.struts.ReservationForm value object
into a airline.hibernate.Reservation object.
    *
    * @param   reservationPersistence   The
airline.hibernate.Reservation object into which the data is to be
copied.
    * @param   reservationForm   The
airline.web.struts.ReservationForm value object containing the data to
be copied.
    */
   protected static void
copyVoToPersistence(airline.hibernate.Reservation
reservationPersistence, airline.web.struts.ReservationForm
reservationForm) throws Exception {
      // Persistence layer specific implementation
          reservationPersistence.setReservationId(reservationForm.getReserv=
ationId());
            reservationPersistence.setPersonIdFk(reservationForm.getPersonI=
dFk());
            reservationPersistence.setFlightIdFk(reservationForm.getFlightI=
dFk());
              reservationPersistence.setRegistrationUtc(reservationForm.get=
RegistrationUtc());
                =20
reservationPersistence.setComment(reservationForm.getComment());
         }

Instead it should probably look more like:

   protected static void
copyVoToPersistence(airline.hibernate.Reservation
reservationPersistence, airline.web.struts.ReservationForm
reservationForm) throws Exception{
       // Persistence layer specific implementation
           reservationPersistence.setComp_id(new
airline.hibernate.ReservationPK(reservationForm.getReservationId(),
reservationForm.getPersonIdFk(), reservationForm.getFlightIdFk()));  =20
           reservationPersistence.setRegistrationUtc(reservationForm.getReg=
istrationUtc());
                =20
reservationPersistence.setComment(reservationForm.getComment());
          }=20

The same issue exists with the "copyPersistenceToVo" method.

Hopefully there is just some sort of configuration that I messed up.=20
The cmp20 version worked fine, though.

Thanks for reading this far...

-Darin


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php