Guest User

Untitled

a guest
Sep 27th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. Exception in thread "main" org.hibernate.MappingException: Could not determine type for: String, at table: STUDENT, for columns: [org.hibernate.mapping.Column(SNAME)]
  2.  
  3. <?xml version = "1.0" encoding = "utf-8"?>
  4.  
  5. <hibernate-mapping>
  6. <class name = "Student" table = "STUDENT" >
  7. <meta attribute="Class description">
  8. This contains Student details.
  9. </meta>
  10. <id name="id" type="int" column="id">
  11. <generator class="native"/>
  12. </id>
  13. <property name="name" column="SNAME" type="String"/>
  14. <property name="mNo" column="MNO" type="String"/>
  15. <property name="marks" column="MARKS" type="String"/>
  16.  
  17. </class>
  18.  
  19. <?xml version = "1.0" encoding = "utf-8"?>
  20.  
  21. <hibernate-configuration>
  22. <session-factory>
  23. <!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQLdialect</property> -->
  24. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  25. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/firsthibernate</property>
  26. <property name="hibernate.connection.user">root</property>
  27. <property name="hibernate.connection.password">asdf</property>
  28. <mapping resource="Student.hbm.xml"/>
  29. </session-factory>
  30.  
  31. public class Student {
  32. private int id;
  33. private String name;
  34. private String mNo;
  35. private String marks;
  36. public int getId() {
  37. return id;
  38. }
  39. public void setId(int id) {
  40. this.id = id;
  41. }
  42. public String getName() {
  43. return name;
  44. }
  45. public void setName(String name) {
  46. this.name = name;
  47. }
  48. public String getmNo() {
  49. return mNo;
  50. }
  51. public void setmNo(String mNo) {
  52. this.mNo = mNo;
  53. }
  54. public String getMarks() {
  55. return marks;
  56. }
  57. public void setMarks(String marks) {
  58. marks = marks;
  59. }
  60.  
  61. import org.hibernate.Session;
  62. import org.hibernate.SessionFactory;
  63. import org.hibernate.Transaction;
  64. import org.hibernate.cfg.Configuration;
  65.  
  66.  
  67.  
  68. public class DemoStudent {
  69.  
  70. public static void main(String[] args) {
  71. Student st=new Student();
  72. st.setId(1);
  73. st.setName("Amit");
  74. st.setmNo("8927070972");
  75. st.setMarks("98%");
  76.  
  77. Configuration cfg=new Configuration();
  78. cfg.configure();
  79. SessionFactory sf=cfg.buildSessionFactory();
  80. Session s=sf.openSession();
  81. Transaction tr=s.beginTransaction();
  82. tr.begin();
  83. s.save(st);
  84. tr.commit();
  85.  
  86. }
Add Comment
Please, Sign In to add comment