enjoyourlife (1) [Avatar] Offline
#1
I import maven project using eclipse(luna) and encounter some errors..

1. xmlns in persistence.xml

<persistence
version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence_2_1.xsd">


Eclipse shows following errors.

... Referenced file contains errors (http://xmlns.jcp.org/xml/ns/persistence_2_1.xsd). For more information..

So, I changed it like below,

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">


2. I cannot find the class in persistence.xml like <class>org.jpwh.model</class>
It seems just package, no class. So, i delete it.


<persistence-unit name="SimplePU">
<jta-data-source>myDS</jta-data-source>
<mapping-file>simple/Queries.xml</mapping-file>
<class>org.jpwh.model</class>

.....
<persistence-unit name="myPU">
<jta-data-source>myDS</jta-data-source>
<class>org.jpwh.helloworld</class>
<class>org.jpwh.helloworld.Message</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>


3. No generator named “X” is defined in the persistence unit – Eclipse JPA
https://gokceng.wordpress.com/2012/01/02/no-generator-named-x-is-defined-in-the-persistence-unit-eclipse-jpa/

4. maven-antrun-plugin problem
You may encounter this problem when you importing maven project. i just disabled it by clicking eclipse error indicator.
Eclipse will insert following configuration to pom.xml

<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-antrun-plugin
</artifactId>
<versionRange>
[1.7,)
</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>


5. some errors in example project like below...

CreditCard_, Item_ classes seems does not exist. Many classes have this kinds of errors.


package org.jpwh.test.bulkbatch;

import org.jpwh.env.JPATest;
import org.jpwh.model.bulkbatch.BankAccount;
import org.jpwh.model.bulkbatch.Bid;
import org.jpwh.model.bulkbatch.CreditCard;
import org.jpwh.model.bulkbatch.CreditCard_;
import org.jpwh.model.bulkbatch.Item;
import org.jpwh.model.bulkbatch.Item_;

....
siebica (3) [Avatar] Offline
#2
Please find some answers below:

2. I believe this is the extension that Hibernate provides for including the package-info.java (the file you can put your named queries inside)

Please check https://docs.jboss.org/hibernate/stable/entitymanager/reference/en/html/configuration.html#setup-configuration-packaging
As an extension to the specification, you can add a package name in the <class> element (eg <class>org.hibernate.eg</class> ). Caution, the package will include the metadata defined at the package level (ie in package-info.java), it will not include all the classes of a given package.


5. The CreditCard_, Item_ metadata classes are generated during the build process and you can find them under model/target/generated-sources/annotations. The book talks about this strongly typed metadata model at page 45 of MEAP v8
424033 (1) [Avatar] Offline
#3
Hello,

I spent hours trying to import the project within Eclipse Luna. I tried different plugins, searched the web for the many error messages I got with no success.

Is it possible for you to provide online an Eclipse version tu run the sample codes (or at least to give us in a README file indications concerning the necessary plugins) ? Because for the moment it looks as if the targeted audience was rather persons having a good knowledge of Maven and Hibernate (or both) than pure Java developers?

Best regards,