rxue / dictionary-jpa

This is your repo dictionary-jpa
https://github.com
0 stars 0 forks source link

dictionary-jpa

Apache License, Version 2.0, January 2004 Maven Central

dictionary-jpa generates 2 types of jars with different usage

How to Use

How to use the uber-JAR

Pre-requisite: Generation of the database schema needs a database. The database should be configured either on base of https://github.com/rxue/dictionary-jpa/blob/main/src/main/resources/META-INF/persistence.xml or user should overwrite the properties in the peristence.xml through command line below

  1. Download the uber-JAR from https://repo1.maven.org/maven2/io/github/rxue/dictionary-jpa/1.4/dictionary-jpa-1.4-uber.jar
  2. run command in the dictionary of the uber-JAR: java -Djakarta.persistence.schema-generation.database.action=create -jar dictionary-jpa-1.4-uber.jar with a database configured on base of the default properties in persistence.xml embedded inside the uber-JAR. NOTE that the value of jakarta.persistence.schema-generation.action has to be set to create since the default value none would not generate database schema

Example command of running the dictionary-jpa-1.4-uber.jar with properties overwriting the properties in the default persistence.xml embedded inside the uber-JAR:

How to use the normal jar in a Maven project with a database containing the schema generated by the uber-JAR above

add the following block to pom.xml

<dependency>
    <groupId>io.github.rxue</groupId>
    <artifactId>dictionary-jpa</artifactId>
    <version>1.6</version>
</dependency>

Repository Design with JPA

Interface design: LexicalItemRepository and ExplanationRepository

Think first from the frontend point of view:

CREATE

READ

UPDATE

DELETE

Unidirectional @ManyToOne Association (Explanation > LexicalItem)

CREATE

READ

UPDATE

DELETE

~This design strategy cannot simply meet the repositories.~

Current Design Conclusion on base of prototyping trial

After trying the bidirectional @ManyToOne association from Explanation back to DictionaryEntry, and then gradually tweaking back to unidirectional, unidirectional @ManyToOne association is eventually decided to be used