Coder Social home page Coder Social logo

sp3's Introduction

plainJpaTemplate

Fork (or clone and delete the .git-folder) this project to get a ready to use template for JPA-development in a plain java project (no web server)

It uses the strategy with an in-memory database to mock away your database for DB-related unit tests

Getting started

  • Clone the project (from your fork) and navigate into the project folder

Change settings in the POM-file

Important: The first thing you should do is, change the following settings in your POM-file:

  • groupId : This will identify your project uniquely across all projects, so you need to enforce a unique naming schema.
  • artifactId: This will be the name of the jar without the version. You can choose "anything" you like for this name
  • version: Leave it as it is for SNAPSHOT versioning, or replace with typical version numbers if you like (1.0, 1.0.1, 1.1, ...)

See higest voted answer for details

Executing the test cases

  • run maven test to execute the simple JUnit Case that ships with the project
  • run maven verifyto execute the simple integration test that ships with the project (this is a copy of the simple Unit-test, it's added to demonstrate how to add integration tests)

This worked, because the project ships with a persistence.xml file in \src\test\resources\META-INF\persistence.xml which uses an in-memory derby database

Setting up your Local Database

Use MySQL Workbench to create a new database for the project (jpademo, for example) The real persistence.xml file is git-ignored, so you don't get it with the project. The project, however, does contain a template in \src\main\resources\META-INF\persistence_TEMPLATE.xml

  • Open this file and (in source mode) change properties to reflect the database you just created
  • Rename this file to persistence.xml
  • Open the project in NetBeans and run the file utils.Tester
  • Verify that this created the Single table in your database

Use the project with your own Entity Classes

Delete the Car class, and just follow the few instructions given in the code

Now your project is ready for you to do great stuff ๐Ÿ˜ƒ

Read this document, and strategy-1 for information about ways to include more than one persistence-unit and/or persistence.xml file, as reference for how this start-project was designed.

Build Status

SP3

sp3's People

Contributors

emssoh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.