hibernate中的异常问题
IllegalArgumentException in class: com.pro.entity.DeviceInformation, getter method of property: id
org.hibernate.PropertyAccessException:
IllegalArgumentException occurred calling getter of com.pro.entity.DeviceInformation.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195)
at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:67)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:67)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:147)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:457)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:113)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:87)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:261)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at com.pro.utils.HibernateSessionFactory.openSession(HibernateSessionFactory.java:24)
at com.pro.utils.Test.main(Test.java:11)
在数据库中DeviceInformation设置的主键ID为varchar型。有另外一个类其采用复合主键的方式,与DeviceInformation存在 多对一的关系
<composite-id name="id" class="PortConfigurationPK">
<key-many-to-one
name="device"
class="com.pro.entity.DeviceInformation"
column="Device_Id"
/>
<key-property
name="portNumber"
column="Port_Number"
type="string"
/>
</composite-id>
请高手解决一下,要怎么处理这个异常