Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 785371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:52:01+00:00 2026-05-14T20:52:01+00:00

is there a skeleton for a project using mysql, some eclipse/top link with RESOURCE_LOCAL

  • 0

is there a skeleton for a project using mysql, some eclipse/top link with RESOURCE_LOCAL as connection type? Preferably using maven. I’m searching for it for hours and can’t get running even the sipmlest exaple. So if you had it ready and running, please, post :-). Even something as simple as these two classes only.


@Entity
public class Message implements Serializable{
    public Message() {}
    public Message(String s){
        this.s = s;
    }
    @Id
    String s;
    public String getS(){
        return s;
    }
}
public class App {
    static private EntityManagerFactory emf;
    static private EntityManager em;
    public static void main( String[] args ) {
        emf = Persistence.createEntityManagerFactory("persistence");
        em = emf.createEntityManager();
        Message m = new Message("abc");
        em.persist(m);
    }
}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:52:02+00:00Added an answer on May 14, 2026 at 8:52 pm

    Maven has an archetype for JPA Application that is available from the internal catalog

    $ mvn archetype:generate 
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'archetype'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO]    task-segment: [archetype:generate] (aggregator-style)
    [INFO] ------------------------------------------------------------------------
    [INFO] Preparing archetype:generate
    [INFO] No goals needed for project - skipping
    [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
    [INFO] Setting property: velocimacro.messages.on => 'false'.
    [INFO] Setting property: resource.loader => 'classpath'.
    [INFO] Setting property: resource.manager.logwhenfound => 'false'.
    [INFO] [archetype:generate {execution: default-cli}]
    [INFO] Generating project in Interactive mode
    [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
    Choose archetype:
    ...
    23: internal -> jpa-maven-archetype (JPA application)
    ...
    Choose a number:  (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41) 15: : 
    

    Or more directly:

    mvn archetype:generate \
      -DgroupId=com.mycompany.myproject \
      -DartifactId=my-project-domain \
      -DpackageName=com.mycompany.myproject.domain \
      -DarchetypeGroupId=com.rfc.maven.archetypes \
      -DarchetypeArtifactId=jpa-maven-archetype  \
      -DarchetypeVersion=1.0.0 \
      -DremoteRepositories=http://maven.rodcoffin.com/repo \
      -DinteractiveMode=false
    

    This will generate a nice project using Hibernate, HSQLDB with a DbUnit test. Now, cd into the created directory to make some changes.

    First of all, edit the pom.xml. Remove the Hibernate related artifacts and replace them by EclipseLink (you’ll need an extra repository):

    <project>
      ...
      <repositories>
        <repository>
          <id>eclipselink</id>
          <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo/</url>
        </repository>
      </repositories>
      <dependencies>
        <!-- See http://wiki.eclipse.org/EclipseLink/Maven -->
        <dependency>
          <groupId>org.eclipse.persistence</groupId>
          <artifactId>eclipselink</artifactId>
          <version>2.0.0</version>
        </dependency>
        <!-- optional - only needed if you are using JPA outside of a Java EE container-->
        <dependency>
          <groupId>org.eclipse.persistence</groupId>
          <artifactId>javax.persistence</artifactId>
          <version>2.0.0</version>
          <scope>provided</scope>
        </dependency>
        ...
      </dependencies>
      ...
    </project>
    

    Then modify the persistence.xml (note that there are 2 persistence units below and the one filled is used during tests):

    <?xml version="1.0"?>
    <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">
      <persistence-unit name="my-project-domain"/>
      <persistence-unit name="my-project-domain-test" transaction-type="RESOURCE_LOCAL">
        <class>com.mycompany.myproject.User</class>
        <properties>
          <property name="eclipselink.target-database" value="HSQL"/>
          <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
          <property name="javax.persistence.jdbc.user" value="sa"/>
          <property name="javax.persistence.jdbc.password" value=""/>
          <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:my-project-test"/>
          <property name="eclipselink.ddl-generation" value="create-tables"/>
        </properties>
      </persistence-unit>
    </persistence>
    

    That’s all. I’ve posted the modified pom.xml on pastebin.com. To use MySQL, add the JDBC driver as dependency in the pom.xml and replicate the EclipseLink configuration. This should be easy and is left as an exercise for the reader 🙂 In case of a blocking problem, leave a comment and I’ll see if I can help.


    If you want to make the test pass again, you’ll have to replace the following lines in UserTest.java:

    HibernateEntityManager em = (HibernateEntityManager) emf.createEntityManager();
    
    DbUnitDataLoader loader = new DbUnitDataLoader(testData, em.getSession().connection());
    

    By

    EntityManager em = emf.createEntityManager();
    Connection conn = em.unwrap(java.sql.Connection.class);
    conn.setAutoCommit(true);
    
    DbUnitDataLoader loader = new DbUnitDataLoader(testData, conn);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 436k
  • Answers 436k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you were on the right track with Expression.NewArrayInit.… May 15, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer First of all, the grammar itself isn't top-down or bottom-up,… May 15, 2026 at 4:05 pm
  • Editorial Team
    Editorial Team added an answer Try this public interface ISaveable { void SaveFields(); } public… May 15, 2026 at 4:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.