gpt4 book ai didi

java - hibernate : Could not determine type for: Integer

转载 作者:行者123 更新时间:2023-12-04 04:46:30 25 4
gpt4 key购买 nike

我收到一条错误消息 Could not determine type for: Integer, at table: t_credential, for columns: [org.hibernate.mapping.Column(id)]运行程序时。

我的 t_credential 数据库有一个 PK 列 id这是由应用程序设置的(​​不是自动增量)。

这是我的 XML 映射文件:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="com.x.com.core.pojo.TUIDInfo" table="t_pop3_credential_messageuid">
<id name="id" column="id" type="integer" >
<generator class="native" />
</id>
<property name="messageUID"><column name="messageUID" /></property>
<many-to-one name="cred" column="credential_id" class="com.x.listener.core.imap.Credential" ></many-to-one>
</class>

<class name="com.x.listener.core.imap.Credential" table="t_credential" >
<id name="id" column="id" type="Integer" >
<generator class="select" />
</id>
<property name="username" column="email" type="String" length="100" />
<property name="password" column="password" type="String" length="100" />
<property name="mailServer" column="mail_server" type="String" length="100" />
<property name="protocol" column="protocol" type="String" length="100" />
<property name="tenant" column="tenant" type="String" />
<property name="host" column="host" type="String" length="100" />
</class>
</hibernate-mapping>

我的 TUID 类(class):
package com.x.com.core.pojo;

import com.x.listener.core.imap.Credential;

public class TUIDInfo {

private Integer id;
private String messageUID;// change accordingly
private Credential cred;



public TUIDInfo( String messageUID, Credential cred) {
super();

this.messageUID = messageUID;
this.cred = cred;

}

public TUIDInfo() {
super();
}

public Integer getid() {
return this.id;
}

public void setid(Integer id) {
this.id = id;
}

public String getMessageUID() {
return this.messageUID;
}

public void setMessageUID(String messageUID) {
this.messageUID = messageUID;
}
public Credential getCred() {
return this.cred;
}

public void setCred(Credential cred ) {
this.cred = cred;
}

}

和我的凭证类:
package com.x.listener.core.imap;
public class Credential {
Integer id;
private String host;// change accordingly
private String username;
private String password;// change accordingly
private String mailServer;
private String protocol;
private String tenant;


public Credential(Integer id, String host, String username,
String password, String mailServer, String protocol, String tenant) {
super();
this.id = id;
this.host = host;
this.username = username;
this.password = password;
this.mailServer = mailServer;
this.protocol = protocol;
this.tenant = tenant;
}

public Credential() {
super();
}

public String getProtocol() {
return protocol;
}

public void setProtocal(String protocol) {
this.protocol = protocol;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getMailServer() {
return mailServer;
}

public void setMailServer(String mailServer) {
this.mailServer = mailServer;
}

public String getTenant() {
return tenant;
}

public void setTenant(String tenant) {
this.tenant = tenant;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

}

最佳答案

尝试将其更改为小写:

<class name="com.x.listener.core.imap.Credential" table="t_credential" >
<id name="id" column="id" type="integer" > <!-- Instead of Integer -->
<generator class="select" />
</id>

正如您在上面使用的那样:
<class name="com.x.com.core.pojo.TUIDInfo" table="t_pop3_credential_messageuid">
<id name="id" column="id" type="integer" >
<generator class="native" />
</id>

关于java - hibernate : Could not determine type for: Integer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18098673/

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