Hi Gilberto,
There's no automated way port a Hibernate project to Cayenne, but you
can certainly do that manually. I would suggest to use Cayenne
traditional non-POJO API (while POJO/JPA stuff is still pre-alpha,
Cayenne API is production quality and has fewer surprises).
The quickest way to do that is probably the following:
* reverse engineer the DB in question with CayenneModeler
* manually tweak the model to match the property names in the
existing POJO Java classes
* Run class generator to generate the _Xyz superclasses.
* Change the existing classes by hand to inherit from _Xyz counterpart.
* Remove existing persistence fields, and use superclass getters and
setters to access them.
* Change the API throughout the code to use Cayenne ObjectContext and
Queries.
Andrus
On Oct 24, 2007, at 10:17 PM, Gilberto C Andrade wrote:
> [This is second email I send, I think the first one get lost]
> Hi all,
>
> I've been searching on docs/maillist about how to persist an already
> existent pojo, but have no luck. Let me explain: we have two old
> projects build with hibernate 2.1.8 and all model are marked with
> hibernate tag on doc area in java source [1].
> But now we want to use those models with cayenne (3.0M1) without edit
> them. Is that possible?
>
>
> These systems included the business and data access in the same place.
> So turning it impossible to change the domain logic. By the way,
> someone
> can suggest a good design separation of package?
> We are now trying this:
> br.to.gov.secad.<module>.model;
> br.to.gov.secad.<module>.dao;
> br.to.gov.secad.<module>.service;
>
>
> Thanks!
>
> Gilberto
>
> PS.: I think we won the battle about ORM choice. Now comes the new
> one:
> beat the eclipse hibernate tools! Thanks all for help!
>
> [1]
> [code]
> /**
> * Área de atuação do curso: informática, RH, financeira, etc.
> * ..ibernate.class table="scc.scc_area"
> */
> public class Area implements Serializable {
>
> /** identifier field */
> private Integer cdArea;
>
> /** persistent field */
> private String dcArea;
>
> /** full constructor */
> public Area(Integer cdArea, String dcArea) {
> this.cdArea = cdArea;
> this.dcArea = dcArea;
> }
>
> /** default constructor */
> public Area() {
> }
>
> /**
> *..ibernate.id generator-class="sequence" column="cdarea"
> unsaved-value = "null"
> *..ibernate.generator-param name = "sequence" value =
> "scc.scc_area_sequence"
> *..eturn Integer
> */
> public Integer getCdArea() {
> return this.cdArea;
> }
>
> public void setCdArea(Integer cdarea) {
> this.cdArea = cdarea;
> }
>
> /**
> * ..ibernate.property column="dcarea" length="40" not-
> null="true"
> *
> */
> public String getDcArea() {
> return this.dcArea;
> }
> [/code]
>
This archive was generated by hypermail 2.0.0 : Thu Oct 25 2007 - 03:37:28 EDT