Spring 数据 JPA Teradata:BYTE 数据与其他类型之间的转换是非法的
Spring data JPA Teradata: Conversion between BYTE data and other types is illegal
我无法将记录插入 table。
保存方式
@Modifying
@Query(value = "LOCKING TABLE JOB_QUEUE FOR WRITE INSERT INTO JOB_QUEUE (FILE_GUID, FILE_TYPE, PIPELINE_NAME, STATE, PRIORITY, DATE_CREATED, REQUEST_USER_ID, SPLIT_BY_BUS, FILTER_ID, GROUP_BY_BUS, RULE_SET, MAP_ID, OUTPUT_PATH, IS_REPLAY, SUBSCRIBING_PARTNER) VALUES (:#{#entity.fileGuid}, :#{#entity.fileType}, :#{#entity.pipelineName}, :#{#entity.state}, :#{#entity.priority}, :#{#entity.dateCreated}, :#{#entity.requestUserId}, :#{#entity.splitByBus}, :#{#entity.filterId}, :#{#entity.groupByBus}, :#{#entity.ruleSet}, :#{#entity.mapId}, :#{#entity.outputPath}, :#{#entity.isReplay}, :#{#entity.subscribingPartner})", nativeQuery = true)
<S extends JobQueue> void saveJobQueue(S entity);
型号Class
@Entity
@Table(
name = "JOB_QUEUE"
)
public class JobQueue implements Serializable {
private static final long serialVersionUID = 1L;
@Column(
name = "DATE_CREATED"
)
private Timestamp dateCreated;
@Column(
name = "FILE_GUID"
)
private String fileGuid;
@Column(
name = "FILE_TYPE"
)
private String fileType;
@Column(
name = "FILTER_ID"
)
private Long filterId;
@Column(
name = "GROUP_BY_BUS"
)
private BigDecimal groupByBus;
@Id
@GeneratedValue(
strategy = GenerationType.IDENTITY
)
private Long id;
@Column(
name = "IS_REPLAY"
)
private BigDecimal isReplay;
@Column(
name = "MAP_ID"
)
private Integer mapId;
@Column(
name = "OUTPUT_PATH"
)
private String outputPath;
@Column(
name = "PIPELINE_NAME"
)
private String pipelineName;
private Integer priority;
@Column(
name = "REQUEST_USER_ID"
)
private String requestUserId;
@Column(
name = "RULE_SET"
)
private String ruleSet;
@Column(
name = "SPLIT_BY_BUS"
)
private BigDecimal splitByBus;
private String state;
@Column(
name = "SUBSCRIBING_PARTNER"
)
private String subscribingPartner;
}
Table 架构
CREATE SET TABLE JOB_QUEUE ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO,
MAP = TD_MAP1
(
ID BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY
(START WITH 1
INCREMENT BY 1
MINVALUE 0
MAXVALUE 999999999999999999
NO CYCLE),
FILE_GUID VARCHAR(250) CHARACTER SET LATIN NOT CASESPECIFIC,
FILE_TYPE VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC,
PIPELINE_NAME VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
STATE VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
PRIORITY INTEGER NOT NULL,
DATE_CREATED TIMESTAMP(6) NOT NULL,
REQUEST_USER_ID VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC,
SPLIT_BY_BUS NUMBER(1,0),
FILTER_ID BIGINT,
GROUP_BY_BUS NUMBER(1,0),
RULE_SET VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC,
MAP_ID INTEGER,
OUTPUT_PATH VARCHAR(500) CHARACTER SET LATIN NOT CASESPECIFIC,
IS_REPLAY NUMBER(1,0) DEFAULT 0 ,
SUBSCRIBING_PARTNER VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC)
UNIQUE PRIMARY INDEX JOB_QUEUE_UPI ( ID );
执行时出现以下异常
2021-08-05T00:30:15,800 ERROR [http-nio-8080-exec-1] o.h.e.j.s.SqlExceptionHelper: [Teradata Database] [TeraJDBC 16.20.00.12] [Error 3532] [SQLState 22018] Conversion between BYTE data and other types is illegal.
2021-08-05T00:30:16,465 ERROR [http-nio-8080-exec-1] o.a.j.l.DirectJDKLog: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not execute statement] with root cause
java.sql.SQLException: [Teradata Database] [TeraJDBC 16.20.00.12] [Error 3532] [SQLState 22018] Conversion between BYTE data and other types is illegal.
更新
空值被映射到 VARBINARY,它已使用 Hibernate 类型映射解析。
Query query = entityManager.createNativeQuery("LOCKING TABLE JOB_QUEUE FOR WRITE INSERT INTO JOB_QUEUE (FILE_GUID, FILE_TYPE, PIPELINE_NAME, STATE, PRIORITY, DATE_CREATED, REQUEST_USER_ID, SPLIT_BY_BUS, FILTER_ID, GROUP_BY_BUS, RULE_SET, MAP_ID, OUTPUT_PATH, IS_REPLAY, SUBSCRIBING_PARTNER) VALUES (CAST(:fileGuid AS VARCHAR(250)), CAST(:fileType AS VARCHAR(100)), CAST(:pipelineName AS VARCHAR(100)), CAST(:state AS VARCHAR(100)), :priority, :dateCreated, CAST(:requestUserId AS VARCHAR(10)), :splitByBus, :filterId, :groupByBus, CAST(:ruleSet AS VARCHAR(100)), :mapId, CAST(:outputPath AS VARCHAR(500)), :isReplay, CAST(:subscribingPartner AS VARCHAR(100)))")
.setParameter("fileGuid", new TypedParameterValue(StandardBasicTypes.STRING, entity.getFileGuid()))
.setParameter("fileType", new TypedParameterValue(StandardBasicTypes.STRING, entity.getFileType()))
.setParameter("pipelineName",
new TypedParameterValue(StandardBasicTypes.STRING, entity.getPipelineName()))
.setParameter("state", new TypedParameterValue(StandardBasicTypes.STRING, entity.getState()))
.setParameter("priority", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getPriority()))
.setParameter("dateCreated",
new TypedParameterValue(StandardBasicTypes.TIMESTAMP, entity.getDateCreated()))
.setParameter("requestUserId",
new TypedParameterValue(StandardBasicTypes.STRING, entity.getRequestUserId()))
.setParameter("splitByBus",
new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getSplitByBus().intValue()))
.setParameter("filterId", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getFilterId()))
.setParameter("groupByBus", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getGroupByBus()))
.setParameter("ruleSet", new TypedParameterValue(StandardBasicTypes.STRING, entity.getRuleSet()))
.setParameter("mapId", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getMapId()))
.setParameter("outputPath", new TypedParameterValue(StandardBasicTypes.STRING, entity.getOutputPath()))
.setParameter("isReplay", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getIsReplay()))
.setParameter("subscribingPartner",
new TypedParameterValue(StandardBasicTypes.STRING, entity.getSubscribingPartner()));
query.executeUpdate();
我无法将记录插入 table。
保存方式
@Modifying
@Query(value = "LOCKING TABLE JOB_QUEUE FOR WRITE INSERT INTO JOB_QUEUE (FILE_GUID, FILE_TYPE, PIPELINE_NAME, STATE, PRIORITY, DATE_CREATED, REQUEST_USER_ID, SPLIT_BY_BUS, FILTER_ID, GROUP_BY_BUS, RULE_SET, MAP_ID, OUTPUT_PATH, IS_REPLAY, SUBSCRIBING_PARTNER) VALUES (:#{#entity.fileGuid}, :#{#entity.fileType}, :#{#entity.pipelineName}, :#{#entity.state}, :#{#entity.priority}, :#{#entity.dateCreated}, :#{#entity.requestUserId}, :#{#entity.splitByBus}, :#{#entity.filterId}, :#{#entity.groupByBus}, :#{#entity.ruleSet}, :#{#entity.mapId}, :#{#entity.outputPath}, :#{#entity.isReplay}, :#{#entity.subscribingPartner})", nativeQuery = true)
<S extends JobQueue> void saveJobQueue(S entity);
型号Class
@Entity
@Table(
name = "JOB_QUEUE"
)
public class JobQueue implements Serializable {
private static final long serialVersionUID = 1L;
@Column(
name = "DATE_CREATED"
)
private Timestamp dateCreated;
@Column(
name = "FILE_GUID"
)
private String fileGuid;
@Column(
name = "FILE_TYPE"
)
private String fileType;
@Column(
name = "FILTER_ID"
)
private Long filterId;
@Column(
name = "GROUP_BY_BUS"
)
private BigDecimal groupByBus;
@Id
@GeneratedValue(
strategy = GenerationType.IDENTITY
)
private Long id;
@Column(
name = "IS_REPLAY"
)
private BigDecimal isReplay;
@Column(
name = "MAP_ID"
)
private Integer mapId;
@Column(
name = "OUTPUT_PATH"
)
private String outputPath;
@Column(
name = "PIPELINE_NAME"
)
private String pipelineName;
private Integer priority;
@Column(
name = "REQUEST_USER_ID"
)
private String requestUserId;
@Column(
name = "RULE_SET"
)
private String ruleSet;
@Column(
name = "SPLIT_BY_BUS"
)
private BigDecimal splitByBus;
private String state;
@Column(
name = "SUBSCRIBING_PARTNER"
)
private String subscribingPartner;
}
Table 架构
CREATE SET TABLE JOB_QUEUE ,NO FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO,
MAP = TD_MAP1
(
ID BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY
(START WITH 1
INCREMENT BY 1
MINVALUE 0
MAXVALUE 999999999999999999
NO CYCLE),
FILE_GUID VARCHAR(250) CHARACTER SET LATIN NOT CASESPECIFIC,
FILE_TYPE VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC,
PIPELINE_NAME VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
STATE VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
PRIORITY INTEGER NOT NULL,
DATE_CREATED TIMESTAMP(6) NOT NULL,
REQUEST_USER_ID VARCHAR(10) CHARACTER SET LATIN NOT CASESPECIFIC,
SPLIT_BY_BUS NUMBER(1,0),
FILTER_ID BIGINT,
GROUP_BY_BUS NUMBER(1,0),
RULE_SET VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC,
MAP_ID INTEGER,
OUTPUT_PATH VARCHAR(500) CHARACTER SET LATIN NOT CASESPECIFIC,
IS_REPLAY NUMBER(1,0) DEFAULT 0 ,
SUBSCRIBING_PARTNER VARCHAR(100) CHARACTER SET LATIN NOT CASESPECIFIC)
UNIQUE PRIMARY INDEX JOB_QUEUE_UPI ( ID );
执行时出现以下异常
2021-08-05T00:30:15,800 ERROR [http-nio-8080-exec-1] o.h.e.j.s.SqlExceptionHelper: [Teradata Database] [TeraJDBC 16.20.00.12] [Error 3532] [SQLState 22018] Conversion between BYTE data and other types is illegal.
2021-08-05T00:30:16,465 ERROR [http-nio-8080-exec-1] o.a.j.l.DirectJDKLog: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not execute statement] with root cause
java.sql.SQLException: [Teradata Database] [TeraJDBC 16.20.00.12] [Error 3532] [SQLState 22018] Conversion between BYTE data and other types is illegal.
更新
空值被映射到 VARBINARY,它已使用 Hibernate 类型映射解析。
Query query = entityManager.createNativeQuery("LOCKING TABLE JOB_QUEUE FOR WRITE INSERT INTO JOB_QUEUE (FILE_GUID, FILE_TYPE, PIPELINE_NAME, STATE, PRIORITY, DATE_CREATED, REQUEST_USER_ID, SPLIT_BY_BUS, FILTER_ID, GROUP_BY_BUS, RULE_SET, MAP_ID, OUTPUT_PATH, IS_REPLAY, SUBSCRIBING_PARTNER) VALUES (CAST(:fileGuid AS VARCHAR(250)), CAST(:fileType AS VARCHAR(100)), CAST(:pipelineName AS VARCHAR(100)), CAST(:state AS VARCHAR(100)), :priority, :dateCreated, CAST(:requestUserId AS VARCHAR(10)), :splitByBus, :filterId, :groupByBus, CAST(:ruleSet AS VARCHAR(100)), :mapId, CAST(:outputPath AS VARCHAR(500)), :isReplay, CAST(:subscribingPartner AS VARCHAR(100)))")
.setParameter("fileGuid", new TypedParameterValue(StandardBasicTypes.STRING, entity.getFileGuid()))
.setParameter("fileType", new TypedParameterValue(StandardBasicTypes.STRING, entity.getFileType()))
.setParameter("pipelineName",
new TypedParameterValue(StandardBasicTypes.STRING, entity.getPipelineName()))
.setParameter("state", new TypedParameterValue(StandardBasicTypes.STRING, entity.getState()))
.setParameter("priority", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getPriority()))
.setParameter("dateCreated",
new TypedParameterValue(StandardBasicTypes.TIMESTAMP, entity.getDateCreated()))
.setParameter("requestUserId",
new TypedParameterValue(StandardBasicTypes.STRING, entity.getRequestUserId()))
.setParameter("splitByBus",
new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getSplitByBus().intValue()))
.setParameter("filterId", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getFilterId()))
.setParameter("groupByBus", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getGroupByBus()))
.setParameter("ruleSet", new TypedParameterValue(StandardBasicTypes.STRING, entity.getRuleSet()))
.setParameter("mapId", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getMapId()))
.setParameter("outputPath", new TypedParameterValue(StandardBasicTypes.STRING, entity.getOutputPath()))
.setParameter("isReplay", new TypedParameterValue(StandardBasicTypes.INTEGER, entity.getIsReplay()))
.setParameter("subscribingPartner",
new TypedParameterValue(StandardBasicTypes.STRING, entity.getSubscribingPartner()));
query.executeUpdate();