Sunday 15 September 2013

java - configuring hyperjaxb to create hibernate mappings and a mysql database -



java - configuring hyperjaxb to create hibernate mappings and a mysql database -

i using hyperjaxb generate java classes xsd file. how can configure generate hibernate annotations, , trigger hbm2ddl create mysql database tables generated classes?

i downloaded purchase order sample hibernate from link, navigated target directory in cmd.exe , ran mvn clean install, resulting folders did not contain java classes, , did not contain hibernate/mysql. working illustration creates downloaded xsd file can plug own xsd file code , have java/hibernate/mysql autogenerated. way can spend time tweaking xsd file resulting java/hibernate/mysql need be.

a code illustration or step step instructions helpful. using eclipse.

**edit: **

the reply question came after posting few other questions. find finish reply question, need review answers other questions, in particular, the 1 @ link.

update

finally appeared op looking generated classes in root directory of project insteadof target\generated-source\xjc, despite tutorial states look:

if browse target/generated-sources/xjc directory, you'll find few generated java files, instance purchaseordertype.java.

i don't understand when nil generated. i've rechecked it, works fine.

my steps are:

download hyperjaxb3-ejb-samples-po-initial-0.5.6-maven-src.zip unzip go hyperjaxb3-ejb-samples-po-initial-0.5.6 mvn clean install

here's get:

[info] ------------------------------------------------------------------------ [info] building hyperjaxb3 samples [po-initial:maven] 0.5.6 [info] ------------------------------------------------------------------------ [info] [info] --- maven-clean-plugin:2.5:clean (default-clean) @ hyperjaxb3-ejb-samples-po-initial-maven --- [info] deleting c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\target [info] [info] --- maven-hyperjaxb3-plugin:0.6.0:generate (default) @ hyperjaxb3-ejb-samples-po-initial-maven --- [info] sources not up-to-date; xjc execution executed. [warning] according java persistence api specification, section 2.1, entities must top-level classes: "the entity class must top-level class." jaxb model not customized top-level local scoping, please utilize <jaxb:globalbinding localscoping="toplevel"/> global bindings customization. org.jvnet.hyperjaxb3.ejb.plugin.ejbplugin [warning] according java persistence api specification, section 2.1, entities must implement serializable interface: "if entity instance passed value detached object (e.g., through remote interface), entity class must implement serializable interface." jaxb model not customized serializable, please utilize <jaxb:serializable/> global bindings customization element create model serializable. org.jvnet.hyperjaxb3.ejb.plugin.ejbplugin [info] [info] --- maven-resources-plugin:2.6:resources (default-resources) @ hyperjaxb3-ejb-samples-po-initial-maven --- [warning] using platform encoding (cp1252 actually) re-create filtered resources, i.e. build platform dependent! [info] copying 1 resource [info] copying 0 resource [info] copying 1 resource [info] [info] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ hyperjaxb3-ejb-samples-po-initial-maven --- [warning] file encoding has not been set, using platform encoding cp1252, i.e. build platform dependent! [info] compiling 5 source files c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\target\classes [info] [info] --- maven-resources-plugin:2.6:testresources (default-testresources) @ hyperjaxb3-ejb-samples-po-initial-maven --- [warning] using platform encoding (cp1252 actually) re-create filtered resources, i.e. build platform dependent! [info] copying 2 resources [info] [info] --- maven-compiler-plugin:2.5.1:testcompile (default-testcompile) @ hyperjaxb3-ejb-samples-po-initial-maven --- [warning] file encoding has not been set, using platform encoding cp1252, i.e. build platform dependent! [info] compiling 5 source files c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\target\test-classes [info] [info] --- maven-surefire-plugin:2.12.4:test (default-test) @ hyperjaxb3-ejb-samples-po-initial-maven --- [info] surefire study directory: c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\target\surefire-reports ------------------------------------------------------- t e s t s ------------------------------------------------------- running roundtriptest detected [file:/c:/projects/workspaces/hj3/dist/hyperjaxb3-ejb-samples-po-initial-0.5.6/target/classes/meta-inf/persistence.xml]. roundtriptest loading entity manager mill properties. roundtriptest loading entity manager mill properties [file:/c:/projects/workspaces/hj3/dist/hyperjaxb3-ejb-samples-po-initial-0.5.6/target/test-classes/persistence.properties]. roundtriptest testing samples. roundtriptest sample directory [c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\src\test\samples]. roundtriptest testing sample [po.xml]. roundtriptest unmarshalling. roundtriptest opening session. roundtriptest saving object. roundtriptest opening session. roundtriptest loading object. roundtriptest closing session. roundtriptest initial object: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <purchaseorder orderdate="1999-10-20"> <shipto country="us"> <name>alice smith</name> <street>123 maple street</street> <city>mill valley</city> <state>ca</state> <zip>90952</zip> </shipto> <billto country="us"> <name>robert smith</name> <street>8 oak avenue</street> <city>old town</city> <state>pa</state> <zip>95819</zip> </billto> <comment>hurry, lawn going wild!</comment> <items> <item partnum="872-aa"> <productname>lawnmower</productname> <quantity>1</quantity> <usprice>148.95</usprice> <comment>confirm electric</comment> </item> <item partnum="926-aa"> <productname>baby monitor</productname> <quantity>1</quantity> <usprice>39.98</usprice> <shipdate>1999-05-21</shipdate> </item> </items> </purchaseorder> roundtriptest source object: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <purchaseorder orderdate="1999-10-20" hjid="1"> <shipto country="us" hjid="2"> <name>alice smith</name> <street>123 maple street</street> <city>mill valley</city> <state>ca</state> <zip>90952</zip> </shipto> <billto country="us" hjid="1"> <name>robert smith</name> <street>8 oak avenue</street> <city>old town</city> <state>pa</state> <zip>95819</zip> </billto> <comment>hurry, lawn going wild!</comment> <items hjid="1"> <item partnum="872-aa" hjid="1"> <productname>lawnmower</productname> <quantity>1</quantity> <usprice>148.95</usprice> <comment>confirm electric</comment> </item> <item partnum="926-aa" hjid="2"> <productname>baby monitor</productname> <quantity>1</quantity> <usprice>39.98</usprice> <shipdate>1999-05-21</shipdate> </item> </items> </purchaseorder> roundtriptest result object: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <purchaseorder orderdate="1999-10-20" hjid="1"> <shipto country="us" hjid="2"> <name>alice smith</name> <street>123 maple street</street> <city>mill valley</city> <state>ca</state> <zip>90952</zip> </shipto> <billto country="us" hjid="1"> <name>robert smith</name> <street>8 oak avenue</street> <city>old town</city> <state>pa</state> <zip>95819</zip> </billto> <comment>hurry, lawn going wild!</comment> <items hjid="1"> <item partnum="872-aa" hjid="1"> <productname>lawnmower</productname> <quantity>1</quantity> <usprice>148.95</usprice> <comment>confirm electric</comment> </item> <item partnum="926-aa" hjid="2"> <productname>baby monitor</productname> <quantity>1</quantity> <usprice>39.98</usprice> <shipdate>1999-05-21</shipdate> </item> </items> </purchaseorder> roundtriptest checking document identity. roundtriptest finished testing sample [po.xml]. roundtriptest finished testing samples. roundtriptest tests run: 1, failures: 0, errors: 0, skipped: 0, time elapsed: 2.552 sec results : tests run: 1, failures: 0, errors: 0, skipped: 0 [info] [info] --- maven-jar-plugin:2.4:jar (default-jar) @ hyperjaxb3-ejb-samples-po-initial-maven --- [info] building jar: c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\target\hyperjaxb3-ejb-samples-po-initial-maven-0.5.6.jar [info] [info] --- maven-install-plugin:2.4:install (default-install) @ hyperjaxb3-ejb-samples-po-initial-maven --- [info] installing c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\target\hyperjaxb3-ejb-samples-po-initial-maven-0.5.6.jar c:\repository\org\jvnet\hyperjaxb3\hyperjaxb3-ejb-samples-po-initial-maven\0.5.6\hyperjaxb3-ejb-samples-po-initial-maven-0.5.6.jar [info] installing c:\projects\workspaces\hj3\dist\hyperjaxb3-ejb-samples-po-initial-0.5.6\pom.xml c:\repository\org\jvnet\hyperjaxb3\hyperjaxb3-ejb-samples-po-initial-maven\0.5.6\hyperjaxb3-ejb-samples-po-initial-maven-0.5.6.pom [info] ------------------------------------------------------------------------ [info] build success [info] ------------------------------------------------------------------------ [info] total time: 12.100 s [info] finished at: 2014-10-09t00:42:10+01:00 [info] final memory: 22m/96m [info] ------------------------------------------------------------------------

full mvn clean install -x log here.

so hope see, works perfectly. please post mvn clean install -x, maybe wrong.

now, concerning question, here's mysql example:

https://github.com/highsource/hyperjaxb3/tree/master/ejb/tests/po-mysql

this project includes snippet of hbm2ddl generation:

https://github.com/highsource/hyperjaxb3/tree/master/ejb/tests/issues

the hbm2ddl commented out reason, not sure if works, should give direction.

java hibernate jaxb hbm2ddl hyperjaxb

No comments:

Post a Comment