hibernate 相关问题

Hibernate是Java语言的对象关系映射(ORM)库,使开发人员能够以远远超出对象/关系映射的方式在其应用程序中使用POJO样式的域模型。

Hibernate 属性转换器整数和字符串

我在休眠实体和DTO对象中有主键的int id,我有相同的int id和String encId作为加密的主键id。每次当我使用 Bean 将实体传输到 DTO 时...

回答 1 投票 0

Spring boot RestControllers 不适用于包含 @Entities 的库

我有一个在 java 17 上运行的 spring boot (3.2.1) 应用程序。我还有包含 @Entity 注释的库。我使用 spring boot 默认 Hibernate 连接到数据库。我可以配合...

回答 1 投票 0

如何优雅地忽略现有的ManyToOne关系?

我的遗留代码在 Hibernate 的一个实体中具有很多关系。 目前其中部分未使用(数据库中存在空值),但 EntityManager 查询(例如刷新())可以...

回答 1 投票 0

Hibernate 数据访问上的 JDBC 异常

在本地机器上一切正常。但是当我尝试在服务器计算机上执行 get 请求时,hibernate 会抛出以下异常: Hibernate 数据访问上的 JDBC 异常:SQLException for SQL [n/...

回答 1 投票 0

Spring Boot中Enum修改后如何自动更新Hibernate检查约束?

我有一个使用 Hibernate 的 Spring Boot 应用程序,最近我向实体类 BlockItemEntity 中使用的枚举 ContactTypeConstant 添加了新值。该实体映射到 PostgreSQL 数据库...

回答 1 投票 0

如何在@OneToMany关系映射的列上使用JPA findBy查询?

如何使用jpa查询从具有@OneToMany关系的列中查找记录? 课后 公开课帖子{ @ID 私有字符串 ID; ... ... @OneToMany(级联 = CascadeType.ALL,

回答 2 投票 0

无法使用 JPA 保存具有 OneToMany 映射的实体

我有具有一对多关系的 Order 和 OrderLineItem。当我保存订单时,我收到 ConstraintViolationException。下面是代码片段。 @实体 @Table(名称=“订单”) @

回答 2 投票 0

将 FetchType.LAZY 与 JBoss/Wildfly 和 JSON 结合使用

在WildFly中,我定义了一个这样的实体: @实体 @Table("订单表") @JsonIgnoreProperties(ignoreUnknown = true) 公共类订单实体{ 私人列表项目; ...

回答 1 投票 0

运行 hibernate-tools-maven-plugins,返回无效的覆盖定义:必须声明元素类型“hibernate-reverse-engineering”

我的pom.xml如下: 我的pom.xml如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Test</groupId> <artifactId>Hibernate_Reveng_Maven</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Hibernate Reveng Gen Java</name> <properties> <project.basedir>C:/Kei/SLIS_git_eclipse_2023_09_20231115_2/Hibernate_Reveng (Not work) </project.basedir> <h2.version>1.4.200</h2.version> </properties> <build> <plugins> <plugin> <groupId>org.hibernate</groupId> <artifactId>hibernate-tools-maven-plugin</artifactId> <version>5.4.29.Final</version> <executions> <execution> <id>entity-generation</id> <phase>generate-sources</phase> <goals> <goal>hbm2java</goal> </goals> <configuration> <ejb3>true</ejb3> <revengFile>${project.basedir}/src/main/resources/reveng.xml</revengFile> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>12.2.0.1</version> </dependency> </dependencies> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-tools-maven-plugin</artifactId> <version>5.4.29.Final</version> </dependency> <!-- https://mvnrepository.com/artifact/com.oracle/ojdbc14 --> <dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>12.2.0.1</version> </dependency> </dependencies> </project> 我的 hibernate.properties 如下并放置在 src/main/resources 中: hibernate.dialect=org.hibernate.dialect.Oracle12cDialect #hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver hibernate.connection.url=jdbc:oracle:thin:@10.9.xxx.xx:25100:dsli01.xxxxx.com hibernate.connection.username=dsli01 hibernate.connection.password=xxxxxx 我的reveng.xml放置在src/main/resources中,如下: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" > <hibernate-reverse-engineering> <!-- This assumes your database connection is pointing to the proper catalog --> <!-- To get all tables in the named schema, use the following <schema-selection match-schema="PM" /> --> <!-- to get only the named tables --> <schema-selection match-schema="dsli01" match-table="UAC_USER_SSN"/> </hibernate-reverse-engineering> 然后当我运行 mvn clean install 时,显示以下错误: [ERROR] Failed to execute goal [32morg.hibernate:hibernate-tools-maven-plugin:5.4.29.Final:hbm2java[m [1m(entity-generation)[m on project [36mHibernate_Reveng_Maven[m: [1;31mExecution entity-generation of goal org.hibernate:hibernate-tools-maven-plugin:5.4.29.Final:hbm2java failed: Could not configure overrides from file: C:\Kei\SLIS_git_eclipse_2023_09_20231115_2\Hibernate_Reveng (Not work)\src\main\resources\reveng.xml[m: invalid override definition: Element type "hibernate-reverse-engineering" must be declared. -> [1m[Help 1][m [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch. [ERROR] Re-run Maven using the [1m-X[m switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 错误是什么意思?我看到我的 reveng.xml 有元素 <hibernate-reverse-engineering> ........ </hibernate-reverse-engineering> Capricorn1 的答案在在此处输入链接描述解决了我的问题。即修改hibernate.reveng.xml文件中的DOCTYPE。 无论如何,问题的根源是什么以及为什么上面可以解决这个问题还不得而知。

回答 1 投票 0

数据库上的事务只读与 Hibernate 上的事务(readOnly=true)

我是一名 Spring 开发人员,我通常使用 @Transactional(readOnly = true) 进行读取操作。我相信这是对 Hibernate 的提示,但我不知道 Hibernate 如何将此提示发送到数据库......

回答 1 投票 0

Hibernate/JPA:加入不同类型的列

在我的 Spring Boot(3.2.3 版本)应用程序中,我有以下两个 JPA 实体: @实体 @Table(名称 = "table_1") @盖特 @塞特 公共类表1 { @EmbeddedId 私人餐桌...

回答 1 投票 0

Hibernate:使用继承时的多个 @Version 列和字段

在 Hibernate 中处理继承时,我遇到了 @Version 的问题。 我使用 InheritanceType.JOINED 解决方案。 我有一个 BaseEntity 定义了一个公共字段 - 包括@Version: @MappedSupe...

回答 1 投票 0

抛出一个不会被 try 块捕获的自定义异常是不好的做法吗?

我有以下代码,RepositoryException将由全局ExceptionHandler处理。 公共类别更新(类别实体){ 尝试 { em = emf.createEntityMa...

回答 1 投票 0

Spring Boot - Hibernate - 表不存在

我有一个第三方 jar,其中包含所有实体和映射。我目前在经典的 Spring-MVC 应用程序中成功使用这个 jar,但现在我尝试在 Spring-Boot 中使用它

回答 8 投票 0

如何更改 Panache/Hibernate 实体的 DTO 中使用 Jackson 序列化的 JSON 结构?

我在我的应用程序中定义了这两个实体: @实体 公共类 Avail 扩展了 PanacheEntity { 公共整数总计; 公共整数限制; @JsonProperty("last_transactions") ...

回答 1 投票 0

@LazyCollection(LazyCollectionOption.FALSE) 和 @OneToMany(fetch = FetchType.EAGER) 之间的区别

我对“延迟加载”有一个疑问。 使用 @LazyCollection(LazyCollectionOption.FALSE) 和 @OneToMany(fetch = FetchType.EAGER) 有什么区别? 在我的应用程序中,我使用两个列表,...

回答 4 投票 0

将具有 Enum 角色的用户插入 PostgreSQL 数据库时出错

我在尝试将具有角色的新用户插入我的 PostgreSQL 数据库时遇到问题。我有一个 Spring Boot 应用程序,其中用户由 UserEntity 类表示,每个......

回答 1 投票 0

在 Spring Data Jpa 中通过级联持久保存关联的分离实体。可以吗?

如果我想在 Spring Data Jpa 中保留一个“新”实体和一个“旧”关联实体怎么办?让我告诉你我的意思 收到注册请求,这是我的处理方式 噗...

回答 1 投票 0

未从连接表获取数据

我有一个多对多的关系,通过这种关系,hibernate 负责处理连接表。我有 2 个实体:服务和服务提供商。服务实体是拥有方,而

回答 1 投票 0

拦截器onSave()后未插入记录

我的应用程序由 spring @transaction 和 hibernate 组成。我正在尝试使用休眠拦截器。我将拦截器注册为 getHibernateTemplate().getSessionFactory().withOptions().intercep...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.