- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的文件src/main/resources/META-INF/persistence.xml
是:
<?xml version="1.0" encoding="UTF-8" ?>
<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" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="todo" transaction-type="RESOURCE_LOCAL">
<class>com.testJPA.classes.Voiture</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:todos" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
</properties>
</persistence-unit>
我的主要类(class)是:
package com.testJPA.classes;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print("Hello");
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("todo");
EntityManager em = emf.createEntityManager();
for (int i = 0; i < 10; i++) {
Voiture car = new Voiture("a", "b", "c");
em.persist(car);
}
em.getTransaction().commit();
// Find the number of Point objects in the database:
Query q1 = em.createQuery("SELECT COUNT(v) FROM Voiture v");
System.out.println("Le nombre d'enregistrement: "
+ q1.getSingleResult());
}
}
我的类(class)“Voiture”是:
package com.testJPA.classes;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Voiture {
@Id private String matricule;
String position;
String vitesse;
public Voiture(String matricule, String position, String vitesse) {
this.matricule = matricule;
this.position = position;
this.vitesse = vitesse;
}
public Voiture() {
this.matricule = "";
this.position = "";
this.vitesse = "";
}
public String getMatricule() {
return matricule;
}
public void setMatricule(String matricule) {
this.matricule = matricule;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getVitesse() {
return vitesse;
}
public void setVitesse(String vitesse) {
this.vitesse = vitesse;
}
}
我遇到此错误:尝试以下发现的实现后,没有可用于“todo”的持久性提供程序
抱歉,我是 JAva EE 初学者
最佳答案
这是一个类路径问题。您需要在已编译类目录的根目录中有 META-INF 目录。
target / classes /
/ com / testJPA / classes / Main.class
/ META-INF / persistence.xml
解决此问题后,您需要删除 openjpa.RuntimeUnenhancedClasses 属性。这是一种邪恶的属性,会让你头疼不已。请阅读this documentation和 this documentation关于如何正确增强您的实体。
关于jpa-2.0 - 没有可用的持久性提供程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10818025/
我想知道将内存中的树结构存储为用于持久性目的的目录树的实用性。在我的例子中,他的目标文件系统将是 ZFS,一旦创建了结构,它将很少被多个进程访问。 使用目录树作为数据树持久化机制的性能如何? 最佳答案
我已经创建了 docker private registry 并且能够从同一网络中的其他 raspi 推送和拉取(将 registry ip 添加到 insecure-registry 选项) doc
我正在尝试构建我的第一个“真正的”Haskell 应用程序,一个使用 Servant 的 API,我在其中使用 Persistent 作为数据库后端。但是我在尝试使用 Persistent 进行某种类
我已经在 stackoverflow 上看到了 ASP.NET MVC C# 中的持久性 cookie 示例。但我不明白为什么下面的代码不起作用。 首先我写入cookie: HttpCookie co
我是 Java Persistence API 的新手.我刚学会它,现在想在我的 Java 桌面应用程序中使用它。但我有以下问题: Q1。哪个 JPA 实现的大小最小(因为我希望我的应用程序的大小尽可
我正在尝试按照 android 蓝图指南将 MVP 模式实现到我的项目中。目前,我将用户(实体数据)保存在我的 Presenter 中,我真的不喜欢这样做,因为在每次配置更改时,presenter 都
我需要一个类似 map 的数据结构(在 C++ 中)来存储具有以下功能的对 (Key,T): 可以在当前结构中插入新元素(Key,T) 可以在当前结构中根据Key搜索元素 您可以制作当前版本结构的“快
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我的配置 MBean 的持久性存在问题。我的配置: @ManagedResource(objectName = "pl.mobile
docker 中的 RabbitMQ 在删除没有卷的容器后丢失数据。 我的 Dockerfile: FROM rabbitmq:3-management ENV RABBITMQ_HIPE_COMPI
我正在尝试编写一个类型类,以简化使用持久性、aeson 和 scotty 编写 CRUD 后端 这是我的想法: runDB x = liftIO $ do info CRUD a where
当我尝试使用 持久化对象时遇到问题多线程 . 详情: 假设我有一个对象 PaymentOrder其中有一个列表 PaymentGroup (一对多关系)和 PaymentGroup包含 CreditT
我想使用纯功能数据结构和以下操作来实现环形缓冲区 通过索引进行高效随机访问 添加到前面 从背面移除 使用持久数据结构的原因是因为我有一个写入器线程和多个读取器线程,并且我想避免读取器阻塞写入器。 这可
persistence.xml 中关于 derby 客户端驱动程序的属性声明应该是什么?例如: 当我想从 Java 更新数据库时,我不断收到下面的异常。 实际上我需要客户端驱动程序而不是 Embed
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
我希望用户即使关闭浏览器也不必登录。我的 cookie 将在一个月后过期。 用户登录成功 $session = CGI::Session->new (undef, undef, {Directory
我正在与 JBOss 作斗争,并且遇到了一个似乎很难解决的问题,但事实证明我不能。当我尝试部署一个简单的 Java Web 应用程序时,遇到异常: org.hibernate.ejb.Hibernat
当使用具有持久性的 Workflow Foundation 时,我们想删除一些(或全部)工作流,这些工作流不再应该被持久化/运行。 我可以使用任何脚本/工具吗? 最佳答案 没有可用于执行此操作的标准
我正在使用 JPA,并且我正在为所有引用实体使用二级缓存。一切正常,我可以从二级缓存中获取实体,因为它们之前已经被选中。 现在,我有两个应用程序,它们都使用相同的数据库(因此它们都使用相同的表、值等)
所以我正在制作一个 spring-boot 应用程序,并且从外部库导入一些数据模型(通过 maven 导入)。我有一些模型,它有一个外部库类型的字段,我希望能够保留它。像这样的东西: package
我是一名优秀的程序员,十分优秀!