Menu

#4 JPA w/o Spring

open
nobody
5
2011-05-05
2011-05-05
sasconsuls
No

Great project, finally a GPL ORM reverse engineering tool that work out of the box!

I would like to see a set of jpa templates that does not need spring. We are building GWT applications that just need some back-end data services -- spring is too much.

I am going to try to strip out the JpaDaoSupport usage from the generated template code, but I'll need some help.

Stuart

Discussion

  • florian_adler

    florian_adler - 2011-05-14

    Hi,

    There is a track called JPA2. It is available via the console or by script (see demo-jpa2.cmd/sh in demo/config).
    In this case there is the ORM mapping but not the DAOs.

    The standard/advanced DAO are only available for spring integration at the moment, but new template (ex: on top of the JPA2 track) can be created.

    Can you give sample of code you wish to generate?

    Best regards,

    Florian.

     
  • sasconsuls

    sasconsuls - 2011-05-15

    The JPA2 stre

    We are looking to keep the annotations out of the domain POJO's so that we can send them on to GWT w/o too much copying (via dozer.)

    So, we want to generate the POJO wi/o annotations and have persistance.xml point ti the *.orm.xml files for the mapped entities.

    I would also be great to generate basic dozer mappings to limit the pieces of the object graph that are serialized.

    I'll work on some sample files.

    Thank-you,
    Stuart

     
  • florian_adler

    florian_adler - 2011-05-16

    Hi Stuart,

    If I understand, basically you want as artifacts:
    - Domain java POJO
    - orm.xml files
    - persistence.xml file

    You can have that by the following configuration

    Command line (if all the following artifacts are in /config/demo)
    model-generation.cmd mp-config-jpa-dozer.xml

    Where mp-config-jpa-dozer.xml w/o enrichment part is like
    <generator-config>
    <configuration>
    ...
    <!-- add your model and enrichment -->
    ...

    <target refname="BackendOnBsla"
    name="default"
    fileName="mp-template-config-jpa-dozer.xml"
    outputdir-root="../../DEV/output/jpa-dozer"
    templatedir-root="../../minuteTemplate/template/framework/bsla">
    </target>

    </configuration>
    </generator-config>

    And mp-template-config-jpa-dozer.xml like

    <target name="BackendOnBsla-forhibernate">
    <architecture-target name="hibernate" description="basic springframework layer architecture"/>
    <plugin name="hibernate3" className="net.sf.minuteProject.plugin.hibernate.Hibernate3"></plugin>
    <plugin name="criteriaUtils" className="net.sf.minuteProject.utils.criteria.CriteriaUtils"></plugin>
    <plugin name="schemaUtils" className="net.sf.minuteProject.plugin.database.SchemaUtils"></plugin>
    <plugin name="mavenUtils" className="net.sf.minuteProject.plugin.maven.MavenUtils"></plugin>
    <plugin name="cacheUtils" className="net.sf.minuteProject.utils.cache.CacheUtils"></plugin>
    <plugin name="referenceDataUtils" className="net.sf.minuteProject.plugin.data.ReferenceDataUtils"></plugin>
    <plugin name="restrictedCodeUtils" className="net.sf.minuteProject.utils.code.RestrictedCodeUtils"></plugin>

    <template-target
    libdir="lib/BslaLibrary.vm"
    tool="velocity"
    outputdir="src/main/java"
    belongToPackage="true">

    <!-- ENTITY OBJECTs -->
    <!-- templates -->
    <template name="DomainObjectUML" templateFileName="DomainObjectUML.vm"
    subdir="" outputsubdir="" technicalPackage="domain"
    file-extension="java" file-prefix="" file-suffix=""
    entity-specific="true" package-specific="false" model-specific="false">
    </template>

    </template-target>

    <template-target
    libdir="lib/BslaLibrary.vm,lib/JPA_LIB.vm"
    tool="velocity"
    outputdir="src/main/resources"
    belongToPackage="true">

    <!-- JPA CONFIGURATION -->

    <template name="JPAMapping" templateFileName="JPA.orm.xml.vm"
    subdir="" outputsubdir="" technicalPackage="persistence"
    file-extension="orm.xml" file-prefix="" file-suffix=""
    entity-specific="true" package-specific="false" model-specific="false">
    </template>

    <template name="JPAPersistenceConfig" templateFileName="JPA.persistence.xml.vm"
    subdir="" outputsubdir="" technicalPackage="persistence"
    file-extension="xml" file-prefix="" file-suffix=""
    entity-specific="false" package-specific="false" model-specific="true">
    </template>
    <!-- JPA CONFIGURATION end -->

    </template-target>

    <template-target
    libdir="lib/BslaLibrary.vm"
    tool="velocity"
    outputdir="src/main/resources"
    belongToPackage="true">

    <!-- MAPPING -->
    <!-- templates -->
    <template name="DozerMapping" templateFileName="DozerMapping.vm"
    subdir="" outputsubdir="" technicalPackage="map"
    file-extension="xml" file-prefix="" file-suffix="Mapping"
    entity-specific="true" package-specific="false" model-specific="false">
    </template>

    </template-target>

    </target>

    It is in JPA1, I do not have for the moment the JPA2 orm.xml (also it should be easy to have it from the JPA2 with annotation counterpart).

    I completely agree that MP can also generate some mapping file (dozer way) and even GWT artifacts too.
    Ideally it has to generate as much as possible of artifacts according to your target technology (remove tedious tasks).

    In the configuration above (mp-template-config-jpa-dozer.xml), you should have the necessary to make some template for Dozer artifact:
    Create a DozerMapping.vm (maybe copy DomainObjectUML.vm) : it will create for each entity a <EntityClassName>Mapping.xml file.
    The configuration structure respects maven convention.

    But I think from the Domain model, you have only one part of the mapping in dozer. How do you find out the other part?
    By convention?
    There is a possibility (at early stage) to create hadoc object (transient) like dto: this could be your second part.

    Hope it helps,

    Best regards,

    Florian.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.