سؤال

I'm using Minuteproject to generate my JPA2 entities.

I use the GUI by running .start-console.sh. and enter all my db connection and package details.
enter image description here

It generates all my classes but with each class package as follows.

package com.fantasy.entities.defautmodel.domain.defautmodel;

I want the following.

package com.fantasy.entities;

Any ideas on how I can change this?!

هل كانت مفيدة؟

المحلول 2

Each minuteproject artefacts has some metadata associated to it. In the case of JPA2 artefact the name is 'DomainEntityJPA2Annotation'. The metadata definitions are found in the mp-template-config-JPA2.xml.

        <template name="DomainEntityJPA2Annotation" templateFileName="DomainEntityJPA2Annotation.vm" 
        subdir="" outputsubdir="" technicalPackage="domain" ...

The metadata attribute 'technicalPackage' deals with technical package definition of the artifact. It is coded to 'domain' value, but in your case you would like to have 'entities' instead. So you have to adapt the technical package directory here. If you do so, I advise you to adapt the technical package for DomainEntityJPA2Metamodel (JPA2 metamodel), DomainEntityJPA2EmbeddedId (for embedded Id) and EnumerationReferenceDataJPA2 (for enumeration) replacing 'domain' by 'entities' where necessary.

For the moment there is no convention (yet) in minuteproject main config to change technical package.

So why do technical package needed?

It is a way to classify among the different stacks, where other tracks dependent of JPA2 can generate upon (ex: DAO, JSF ...).

Business package

Alongside technical, minuteproject add the notion of business package, it is a way to gather your entities per business aspect (admin, finance, ...)

If you do not add any business package it gives the package of the model. If you do not provide any model name (like on the example on the console) then the default model name 'defaultmodel' is given.

I hope it helps.

نصائح أخرى

Looks like this page explains: http://minuteproject.wikispaces.com/JPA2SmartRE

I got it to set to the following:

com.fantasy.domain.entities

With this confg file:

<!DOCTYPE root>
<generator-config xmlns="http://minuteproject.sf.net/xsd/mp-config"
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    xs:noNamespaceSchemaLocation="mp-config.xsd">
    <configuration>
        <model name="fantasy" version="1.0" package-root="com">
            <data-model>
                <dataSource>
                    <driverClassName>org.gjt.mm.mysql.Driver</driverClassName>
                    <url>jdbc:mysql://127.0.0.1:3306/fantasy</url>
                    <username>root</username>
                    <password></password>
                </dataSource> 
                <primaryKeyPolicy oneGlobal="true" oneForEachTable="false">
                    <primaryKeyPolicyPattern prefix="" suffix="" name="sequencePattern" sequenceName="hibernate_sequence"></primaryKeyPolicyPattern>
                </primaryKeyPolicy>
            </data-model>
            <business-model>
                <generation-condition>
                    <condition type="exclude" startsWith="DUAL"></condition>
                    <condition type="exclude" startsWith="ID_GEN"></condition>
                </generation-condition>
                <business-package default="entities">
                     <condition type="package" startsWith="*" result="entities"></condition>
                </business-package>
                <enrichment>
                    <conventions>
                        <entity-naming-convention type="apply-strip-table-name-prefix" pattern-to-strip="SYS,FIN"/>
                        <column-naming-convention type="apply-fix-primary-key-column-name-when-no-ambiguity" default-value="ID"/>
                        <reference-naming-convention type="apply-referenced-alias-when-no-ambiguity" is-to-plurialize="true"></reference-naming-convention>
                    </conventions>

                     <package name="entities">
                     <entity-group entities="*"></entity-group>
                     </package>
                </enrichment>
            </business-model>
            <statement-model>
            </statement-model>
        </model>
        <targets catalog-entry="JPA2" />
    </configuration>
</generator-config>

I simply cannot figure out how to remove the 'domain' part! Documentation is fairly poor.

I'll just run a perl reg exp to update all my class's as follows:

perl -e 's/com.fantasy.domain/com.fantasy/g;' -pi $(find . -type f)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top