Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iandarwin/jpademo
A ton of JPA and Hibernate tutorial demos, both APIs demo'd on the same entities
https://github.com/iandarwin/jpademo
database hibernate java jpa orm persistence
Last synced: about 10 hours ago
JSON representation
A ton of JPA and Hibernate tutorial demos, both APIs demo'd on the same entities
- Host: GitHub
- URL: https://github.com/iandarwin/jpademo
- Owner: IanDarwin
- License: other
- Created: 2014-02-20T02:18:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-29T18:37:41.000Z (3 months ago)
- Last Synced: 2024-10-12T20:32:52.943Z (about 1 month ago)
- Topics: database, hibernate, java, jpa, orm, persistence
- Language: Java
- Homepage:
- Size: 20.1 MB
- Stars: 2
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE.txt
Awesome Lists containing this project
README
== jpademo
This project contains the MusicRecording/VideoRecording portion of the domain model,
and has both Hibernate and JPA versions of many of the demo
programs, including the famous (working) ManyToManyDemo.The domain model is annotated using JPA annotations, and is used by *both
sets of demos - JPA and Hibernate - without change*.This notion-of using both JPA and the Hibernate API to access the same entities-
is explored http://darwinsys.com/java/hibernate-jpa.html[on my Java web site].Further, the *JPA demos can run using either Hibernate or EclipseLink
as their JPA provider*; see the persistence.xml file for the properties
to change.Currently works with Eclipse (M2E plugin required!) and builds with Maven.
To run any of the demos in Maven, use e.g.,:mvn exec:java -Dexec.mainClass=jpa.JpaSimple
Has in the past been run with H2, HSQLDB, MySQL and PostgresQL just by changing which set
of DB parameters is not commented out in persistence.xml.Should work with any Java from this decade or part of the last;
was recently tested with Java 8 just before upgrading it to Java 17.
If you're stuck on a pre-legacy version of Java, you should upgrade to Java 17 or at least 11.
If you absolutely can't, you might
checkout revision 9084d9e1aa1ac1c261a5bf2dc8cdc8cd180b8162 and stay there
until you get a current Java SE / JDK implementation.
But be aware that branch is *not maintained* and will not even receive security updates,
so _use at own risk!!_=== Quick Rainforest Demo
* Clone the repo
* Open in an IDE
* Overview the domain.media package
* Show code in classes Recording, MusicRecording, VideoRecording and Actor.
* run jpa.Basic, jpa.ManyToMany, jpa.RainListerJpa, etc.
* For "record", show code in Person.java and in PersonRecord.java, run jpa.PersonRecordDemo.=== Database Setup
H2 runs in-memory, in-VM, so no setup is needed.
For PostgreSQL, you can use the handy _psql_ command-line client for any pre-setup.
Once you have your authorization set up as per the Postgres documentation,
it can be as simple as[source]
----
ian=# create user student login password 'student';
CREATE ROLE
ian=# create database jpademo owner student;
CREATE DATABASE
ian=#
----This is explored a bit more fully in the file PostgreSQL.adoc / PostgreSQL.html.
For MySQL, there is a command line client but it is very well hidden
(e.g., on Mac OS, it installs in /usr/local/mysql-5.6.21-osx10.8-x86_64/bin/mysql).
Instead, we offer a guided click-through; see the MySQL.adoc / MySQL.html
file which has many screenshots with instructions.DO NOT USE student/student as credentials on any machine that is accessible from the Internet!!
== TODO
There should be a SEQUENCE demo someplace.