Recently in doing a small Web program, encountered a number of small problems, after the little brother's efforts have been resolved one after another, rejoice in the hope that these solutions choose one or two share with you. These problems are relatively elementary, master will not have to look, so as not to waste time, hehe.
Exception 1:*.hbm.xml element configuration exception in configuration file
Throw Exception Description:
Org.springframework.orm.hibernate3.HibernateSystemException:ids for this class must is manually assigned before calling Save (): Com.ebupt.ncsp.assist.service.department.domain.Department; Nested exception is org.hibernate.id.IdentifierGenerationException:ids to this class must be manually assigned Ling Save (): Com.ebupt.ncsp.assist.service.department.domain.Departmentorg.hibernate.id.IdentifierGenerationException:ids For this class must is manually assigned before calling Save (): Com.ebupt.ncsp.assist.service.department.domain.Department
Error or cause of exception:
The element is not configured correctly and the element is missing the configuration of its child elements.
Workaround:
The element maps the primary key field of the corresponding database table, and for its child elements, the value of class can be increment, identity, sequence, hilo, native ... And so on, more reference Hibernate reference documents, generally take the value of native.
In the configuration *. hbm.xml file I did not use the automatic generation tool, directly manually configured, which is also my carelessness, coupled with the hibernate reference is not very familiar, just according to gourd painting scoop, suggest everyone (novice) to see more reference documents, is very helpful.
Exception 2:*.hbm.xml element configuration exception in configuration file
Throw Exception Description:
Org.springframework.orm.hibernate3.HibernateSystemException:exception Setting property value with Cglib (set Hibernate.cglib.use-reflection-optimizer=false for more info) setter of Com.info.beran.com.SetComCode nested exception is Org.hibernate.PropertyAccessException:setting property value with Cglib (set Hibernate.cglib.use-reflection-optimizer=false for more info)
Error or cause of exception:
1. The types of fields in a database table (typically numeric fields) are inconsistent with the types configured in the configuration file.
2. In the database, the value of the numeric field is null.
The corresponding solution:
1. The type that modifies the type of the field in the configuration file to be the same is an integer.
2. Because null cannot be assigned to the original type, the field type (long, int, tinyint) of the numeric type in the metabase is mapped to an object type integer problem.
In fact, the above two exceptions are not encountered when mapping using the tool that automatically generates the configuration file, and I would like to cite these two examples to help you.