gpt4 book ai didi

mysql - Hibernate 无法映射 MySQL varchar(255)

转载 作者:行者123 更新时间:2023-11-30 21:59:19 25 4
gpt4 key购买 nike

如何定义此列?我试过:

    //@Column(name="GLN_NM", nullable=false, length=255)
//@Column(name="GLN_NM", nullable=false)
//@Column(name="GLN_NM", nullable=false, columnDefinition="varchar(255)")
//@Column(name="GLN_NM", nullable=false, type="text")
//@Column(name="GLN_NM", nullable=false, columnDefinition="text")
//@Column(name="GLN_NM", nullable=false, columnDefinition="TextType")
@Column(name="GLN_NM", length=255)
private String glnNm;

我看到的问题是由以下原因引起的:org.hibernate.tool.schema.spi.SchemaManagementException: 架构验证:在表 [gs1_gpc] 的列 [GPC_NM] 中遇到错误的列类型;找到 [text (Types#LONGVARCHAR)],但期待 [longtext (Types#CLOB)]

软件堆栈* MySQL 5.7.17* mysql-connector-java-5.1.41* sbt 0.13.15* hibernate-core-5.2.10.Final* hibernate-jpa-2.1-api-1.0.0.Final* hibernate-entitymanager-5.2.10.Final* hibernate validator :5.2.4.Final* hibernate-commons-annotations-5.0.1.Final.jar

我已阅读 https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html和几篇文章: 6207788 , 16641758 , 40884306 , 28588311 , 26774193 , 3868096 , 12398597 , 8355669 , 12672764 , 10043556 , 1262174 .

Open Product Data ( http://www.product-open-data.com/download/ ) 将表定义为:

"Field"         "Type"      "Null"  "Key"   "Default"
"GCP_CD" "varchar(13)" "NO" "PRI" \N
"GLN_CD" "varchar(13)" "NO" "" \N
"GLN_NM" "varchar(255)" "NO" "" \N
"GLN_ADDR_02" "varchar(38)" "NO" "" \N
"GLN_ADDR_03" "varchar(38)" "NO" "" \N
"GLN_ADDR_04" "varchar(38)" "NO" "" \N
"GLN_ADDR_POSTALCODE" "varchar(38)" "NO" "" \N
"GLN_ADDR_CITY" "varchar(38)" "NO" "" \N
"GLN_COUNTRY_ISO_CD" "varchar(38)" "NO" "" \N
"CONTACT_NAME" "varchar(38)" "NO" "" \N
"CONTACT_TEL" "varchar(255)" "NO" "" \N
"CONTACT_HOTLINE" "varchar(255)" "YES" "" \N
"CONTACT_FAX" "varchar(255)" "NO" "" \N
"CONTACT_MAIL" "varchar(255)" "NO" "" \N
"CONTACT_WEB" "varchar(255)" "NO" "" \N
"GLN_LAST_CHANGE" "varchar(10)" "NO" "" \N
"GLN_PROVIDER" "varchar(13)" "NO" "" \N
"SEARCH_GTIN_CD" "varchar(13)" "NO" "" \N
"GEPIR_GCP_CD" "varchar(13)" "NO" "" \N
"ADD_PARTY_ID" "varchar(13)" "NO" "" \N
"RETURN_CODE" "varchar(3)" "NO" "" \N
"SOURCE" "varchar(100)" "NO" "" \N
"SYNC_DT" "date" "YES" "" \N

提前致谢。

最佳答案

没有必要在你的 pojo 中像 columnDefinition="text"那样指定 columnDefinition。

只需放入您的 pojo:@Column(name="GLN_NM") 私有(private)字符串 glnNm;

在您的 mysql 中将该列定义为:varchar(256) 或 LongText 或 MediumText 根据您的要求。

关于mysql - Hibernate 无法映射 MySQL varchar(255),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43948934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com