问题 :
何时以及如何创建 JDBC 表?因为奇怪的是我找不到任何用户表。我觉得奇怪的是用户和 Dish 之间有一个多对多关系的表,但没有用户表来存储该用户的名称和密码。
结构:
- 用户:
String name
String password
List<Dish> shoppingList
- 成分 :
String name
- 成分数量:
Ingredient ingredient
Quantity quantity
- 数量 :
int quantity
String unit
- 盘子 :
String name
int people
Collection<IngredientQuantity> ingredients
JDBC:
持久化单元:
<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/persistence_2_1.xsd">
<persistence-unit name="ShoppingCalendarPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>domain.Dish</class>
<class>domain.Ingredient</class>
<class>domain.User</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/ShoppingCalendarDB"/>
<property name="javax.persistence.jdbc.password" value="app"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.user" value="app"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>