字符串数据,右截断 - 使用 Spring Boot 进行休眠
Posted
技术标签:
【中文标题】字符串数据,右截断 - 使用 Spring Boot 进行休眠【英文标题】:string data, right truncation - Hibernate with Spring Boot 【发布时间】:2017-03-22 17:23:56 【问题描述】:所以我的实体类工作得很好。今天我添加了一个新字段:
ButtonTargetBehavior buttonTargetBehavior;
ButtonTargetBehavior 是一个接口(它实现了 Serializable)。每当我现在尝试运行我的 Spring Boot 应用程序时,我都会得到这个
string data, right truncation
引用该字段的错误(是的,我实际上保存了一个实现接口的类的实例,例如:
public class RandomButtonTargetBehavior implements ButtonTargetBehavior
)。
我使用 HSQLDB 进行测试,使用 mysql 进行生产。我需要做什么?
【问题讨论】:
尝试使用@Type
注解可能会解决您的问题
没用。我像@PRATHAP S @Type(type = "com.package.class") 一样使用它
由***.com/questions/2121860/… 修复。我认为最合适的解决方案是自定义类型
如何在实体类中添加接口作为字段?你想达到什么目的?
@PRATHAPS 这是一个接口的实例。特别是行为。课程和项目可以在这里找到:github.com/carloworks/masher/blob/master/src/main/java/com/…
【参考方案1】:
由Storing Objects in columns using Hibernate JPA 修复。我认为最合适的解决方案是自定义类型。
【讨论】:
以上是关于字符串数据,右截断 - 使用 Spring Boot 进行休眠的主要内容,如果未能解决你的问题,请参考以下文章
bcp:错误= [Microsoft] [SQL Server Native Client 10.0]字符串数据,右截断
bcp:错误 = [Microsoft][SQL Server Native Client 10.0]字符串数据,右截断