初学hibernate,遇到这样一个问题。搞了半天都不知道问题出在哪儿,结果发现是配置文件中的类型写法出了问题。
Exception in thread "main" java.lang.ExceptionInInitializerError
at hib.HibernateUtil.<clinit>(HibernateUtil.java:21)
at hib.dynamicmodel.DynamicDemo.main(DynamicDemo.java:24)
Caused by: org.hibernate.MappingException: Could not determine type for: String, for columns: [org.hibernate.mapping.Column(name)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
<property name = "name" column="name" type = "string"/>
开始我写的是 type = "String",正确的因该是上面的,type = "string"
type指的是hibernate中的类型,不是java中的String类型,必须小写。
下面是Java类型,hibernate类型 sql类型对照表:
Hibernate映射类型对照表
java类型 Hibernate映射类型 | SQL类型java.math.BigDecimal | big_decimal | numericbyte[] | binary | varbinary(blob)boolean(java.lang.Boolean) | boolean | bitbyte(java.lang.Byte) byte tinyintjava.util.Calendar | calendar | timestampjava.sql.Clob | clob | clobjava.util.Date 或java.sql.Date | date | datedouble(java.lang.Double) | double | doublefloat(java.lang.Float) | float | floatint (java.lang.Integer) | integer | integerjava.util.Local | local | varcharlong(java.lang.Long) | long | bigintjava.io.Serializable的某个实例 | serializable | varbinary(或blob)java.lang.String | string | varcharjava.lang.String | text | clobjava.util.Date 或 java.sql.Timestamp | time | timestamp |
分享到:
相关推荐
Happily UTF-8 is designed so that it is relatively easy to count the number of unicode symbols in a string: simply count the number of octets that are in the ranges 0x00 to 0x7f (inclusive) or 0xC2 to...
On the other hand, you must include the header file for Foo if your class subclasses Foo or has a data member of type Foo. Sometimes it makes sense to have pointer (or better, scoped_ptr) members ...
Disassembler - fix for error emitted for unknown type for target of scope operator. Now, ignore it and continue. Disassembly of an FADT now verifies the input FADT and reports any errors found. Fix ...
equivalence class clusters for NIL entities (those that could not be linked to an entity in the knowledge base), and entity type information for each of the queries. The data included in this ...
Delphi's THandle type when a HWND is passed to a function. E.g.: if (DragDetectPlus(THandle(MyControl->Handle), Point(X, Y))) { ... } * Virtual File Stream formats can only be pasted from the ...
To determine the transaction isolation level currently set, use the DBCC USEROPTIONS statement, for example: USE pubs GO SET TRANSACTION ISOLATION LEVEL REPEATABLE READ GO DBCC USEROPTIONS GO ...
- Determine and select max physical address size automatically at configure time: - 32-bit physical address for 386/486 guests - 36-bit physical address for PSE-36 enabled Pentium guest - 40-bit ...
An empty string can be denoted by simply not writing anything after the equal ; sign, or by using the None keyword: ; foo = ; sets foo to an empty string ; foo = None ; sets foo to an empty string ;...
14. If the two ISPs do not peer with each other, then when they send traffic to each other they have to send the traffic through a provider ISP (intermediary), to which they have to pay for carrying ...
This specification was developed in response to a perceived need for a standardized programming inter-face to digitizing tablets, three dimensional position sensors, and other pointing devices by a ...
compared with field measurements to evaluate accuracies and determine how water surface roughness and point density affect LiDAR measurements. Results show that LiDAR derived water surface slopes were...