简体   繁体   English

无法确定以下类型的字符串:字符串,在表:STUDENT,对于列:[org.hibernate.mapping.Column(SNAME)]

[英]Could not determine type for: String, at table: STUDENT, for columns: [org.hibernate.mapping.Column(SNAME)]

how to resolve this exception... please help me... while I am executing this simple hibernate programme. 在我执行此简单的休眠程序时,如何解决此异常...请帮助我。 I am getting this exception : 我收到此异常:

Exception in thread "main" org.hibernate.MappingException: Could not determine type for: String, at table: STUDENT, for columns: [org.hibernate.mapping.Column(SNAME)]

mapping file: 映射文件:

<?xml version = "1.0" encoding = "utf-8"?>

<hibernate-mapping>
<class name = "Student" table = "STUDENT" >
    <meta attribute="Class description">
        This contains Student details.
    </meta>
    <id name="id" type="int" column="id">
        <generator class="native"/>
    </id>
    <property name="name" column="SNAME" type="String"/>
    <property name="mNo" column="MNO" type="String"/>
    <property name="marks" column="MARKS" type="String"/>

</class>

configuration file: 配置文件:

<?xml version = "1.0" encoding = "utf-8"?>

<hibernate-configuration>
<session-factory>
    <!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQLdialect</property> -->
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/firsthibernate</property>
    <property name="hibernate.connection.user">root</property>
    <property name="hibernate.connection.password">asdf</property>
    <mapping resource="Student.hbm.xml"/>
</session-factory>

Pojo class: Pojo课:

public class Student {
private int id;
private String name;
private String mNo;
private String marks;
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getmNo() {
    return mNo;
}
public void setmNo(String mNo) {
    this.mNo = mNo;
}
public String getMarks() {
    return marks;
}
public void setMarks(String marks) {
    marks = marks;
}

} }

Test class: 测试类别:

import org.hibernate.Session;    
import org.hibernate.SessionFactory;    
import org.hibernate.Transaction;    
import org.hibernate.cfg.Configuration;



public class DemoStudent {

public static void main(String[] args) {
    Student st=new Student();
    st.setId(1);
    st.setName("Amit");
    st.setmNo("8927070972");
    st.setMarks("98%");

    Configuration cfg=new Configuration();
    cfg.configure();
    SessionFactory sf=cfg.buildSessionFactory();
    Session s=sf.openSession();
    Transaction tr=s.beginTransaction();
    tr.begin();
    s.save(st);
    tr.commit();

}

} }

Thanks in advance... while I am executing this simple hibernate programme. 预先感谢...当我执行这个简单的休眠程序时。 I am getting this please help me where I am doing mistake in this programme. 我得到这个,请在​​我在该程序中出错的地方提供帮助。

In hibernate mapping file use type as string instead of String. 在休眠映射文件中,使用type作为字符串,而不是String。

<property name="name" column="SNAME" 
type="string"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.hibernate.MappingException:无法确定以下类型:表:对于列:[org.hibernate.mapping.Column(plant) - org.hibernate.MappingException: Could not determine type for: at table: for columns: [org.hibernate.mapping.Column(plant) 无法确定以下表的类型:org.json.JSONObject,在表:ordersinfo中,用于列:[org.hibernate.mapping.Column(items)] - Could not determine type for: org.json.JSONObject, at table: ordersinfo, for columns: [org.hibernate.mapping.Column(items)] 无法确定类型 <DataType> 在表:TableX中,用于org.hibernate.mapping.Column(userPrefs)列 - could not determine type for <DataType> at table: TableX, for columns org.hibernate.mapping.Column(userPrefs) org.hibernate.MappingException:无法确定类型:java.util.Set,在表:Company中,用于列:[org.hibernate.mapping.Column(users)] - org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: Company, for columns: [org.hibernate.mapping.Column(users)] org.hibernate.MappingException:无法确定类型:java.util.List,在表:大学,列:[org.hibernate.mapping.Column(students)] - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: College, for columns: [org.hibernate.mapping.Column(students)] org.hibernate.MappingException:无法确定类型:java.util.List,在表:user处,用于列:[org.hibernate.mapping.Column(events)] - org.hibernate.MappingException: Could not determine type for: java.util.List, at table: user, for columns: [org.hibernate.mapping.Column(events)] 引起:org.hibernate.MappingException:无法确定类型:时间戳,列:[org.hibernate.mapping.Column(***)] - Caused by: org.hibernate.MappingException: Could not determine type for: Timestamp, for columns: [org.hibernate.mapping.Column(***)] 无法确定类型:java.util.List,在表:file_post,列:[org.hibernate.mapping.Column(file)] - Could not determine type for: java.util.List, at table: file_post, for columns: [org.hibernate.mapping.Column(file)] 无法确定以下类型:com.packt.cardatabase.domain.Owner,在表:car上,用于列:[org.hibernate.mapping.Column(owner)] - Could not determine type for: com.packt.cardatabase.domain.Owner, at table: car, for columns: [org.hibernate.mapping.Column(owner)] 无法确定类型:TIMESTAMP,表:BATCH_JOB_CONFIG_DTLS,列:[org.hibernate.mapping.Column(ADD_USER_DTM)] - Could not determine type for: TIMESTAMP, at table: BATCH_JOB_CONFIG_DTLS, for columns: [org.hibernate.mapping.Column(ADD_USER_DTM)]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM