gpt4 book ai didi

java - 操作数类型冲突 : datetime2 is incompatible with tinyint

转载 作者:行者123 更新时间:2023-11-30 06:16:41 24 4
gpt4 key购买 nike

我无法利用现有信息解决我的问题

Operand type clash: datetime2 is incompatible with tinyint

此问题仅在使用mssql时出现,希望有人已经知道此问题的解决方案

当切换到mssql时,出现了很多问题,但这仍然只是其中之一,因为其中一些我设法解决了

@Entity
@Table
public class DoseAssignment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Integer id;

@NotNull
@Size(min = 2, max = 30)
@Column(length = 30, nullable = false)
private String number;

@NotNull
@Column(columnDefinition = "tinyint", nullable = false)
private Integer unit;

@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd",
timezone = "UTC")
private Date date;

@NotNull
@Column(nullable = false)
@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd",
timezone = "UTC")
private Date dateOpenPlan;

@NotNull
@Column(nullable = false)
@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd",
timezone = "UTC")
private Date dateClosePlan;

@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd",
timezone = "UTC")
private Date dateOpen;

@Temporal(TemporalType.DATE)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd",
timezone = "UTC")
private Date dateClose;

@ManyToOne(fetch = FetchType.LAZY)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Personal givePersonal;

@ManyToOne(fetch = FetchType.LAZY)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private WorkMode workMode;

@ManyToOne(fetch = FetchType.LAZY)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private ProgramDangerous program;

@NotNull
@Size(min = 2, max = 100)
@Column(length = 100, nullable = false)
private String content;

Controller

Page<Integer> page = repository.findId(department == null ? null : new Department(department), number, unit, workMode == null ? null : new WorkMode(workMode), apartment == null ? new Integer[]{0} : apartment, personal == null ? new Integer[]{0} : personal, program, access, outer, dateOpenPlanFrom, dateOpenPlanTo, dateOpenFrom, dateOpenTo, dateAccessFrom, dateAccessTo, protectionEquipment  == null ? new Integer[]{0}: protectionEquipment, status, pageable);

查询

@Query("select a.id from DoseAssignment a where (:id is null or a.id=:id) and (:department is null or a.department=:department) and (:unit is null or a.unit=:unit) and (:workMode is null or a.workMode=:workMode) and (:program is null or :program=false and a.program is null or :program=true and a.program is not null) and (:dateOpenPlanFrom is null or a.dateOpenPlan>=:dateOpenPlanFrom) and (:dateOpenPlanTo is null or a.dateOpenPlan<=:dateOpenPlanTo) and (:dateOpenFrom is null or a.dateOpen>=:dateOpenFrom) and (:dateOpenTo is null or a.dateOpen<=:dateOpenTo) and (:status is null or a.status=:status) and (:access is null or :access=true and a.status=4 or :access=false and not a.status=4) and ((not 0 in :apartment or not 0 in :personal or :outer is not null or :dateAccessFrom is not null or :dateAccessTo is not null or not 0 in :protectionEquipment) and a.id in (select distinct ai.id from DoseAssignment ai left join ai.protectionEquipment pei left join ai.personal pi left join ai.apartment api left join ai.assignmentAccess aai where (:department is null or ai.department=:department) and (:unit is null or ai.unit=:unit) and (:workMode is null or ai.workMode=:workMode) and (:program is null or :program=false and ai.program is null or :program=true and ai.program is not null) and (:dateOpenPlanFrom is null or ai.dateOpenPlan>=:dateOpenPlanFrom) and (:dateOpenPlanTo is null or ai.dateOpenPlan<=:dateOpenPlanTo) and (:dateOpenFrom is null or ai.dateOpen>=:dateOpenFrom) and (:dateOpenTo is null or ai.dateOpen<=:dateOpenTo) and (:status is null or ai.status=:status) and (0 in :personal or pi.id in :personal) and (0 in :apartment or api.id in :apartment) and (0 in :protectionEquipment or pei.id in :protectionEquipment) and (:dateAccessFrom is null or aai.enterDate>=:dateAccessFrom) and (:dateAccessTo is null or aai.enterDate<=:dateAccessTo) and (:outer is null or :outer=true and pi.type=2 or :outer=false and a.id not in (select distinct aii.id from DoseAssignment aii left join aii.personal pii where pii.type=2))) or not (not 0 in :apartment or not 0 in :personal or :outer is not null or :dateAccessFrom is not null or :dateAccessTo is not null or not 0 in :protectionEquipment))")

.

Page<Integer> findId(@Param("department") Department department, @Param("id") Integer id, @Param("unit") Integer unit, @Param("workMode") WorkMode workMode, @Param("apartment") Integer[] apartment, @Param("personal") Integer[] personal, @Param("program") Boolean program, @Param("access") Boolean access, @Param("outer") Boolean outer, @Param("dateOpenPlanFrom") Date dateOpenPlanFrom, @Param("dateOpenPlanTo") Date dateOpenPlanTo, @Param("dateOpenFrom") Date dateOpenFrom, @Param("dateOpenTo") Date dateOpenTo, @Param("dateAccessFrom") Date dateAccessFrom, @Param("dateAccessTo") Date dateAccessTo, @Param("protectionEquipment") Integer[] protectionEquipment, @Param("status") Integer status, Pageable pageable);

最佳答案

datetime2 类型的大小为 6-8 个字节(包含日期的日期和时间部分),而tinyint 类型为 1 个字节,包含 0-255 的值。您无法将 10 磅的重物放入 1 盎司的容器中。

关于java - 操作数类型冲突 : datetime2 is incompatible with tinyint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49053936/

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