Problems with SSH framework integration-Series 1

Source: Internet
Author: User

1. cocould not find a getter for... in class... exception Solution

Cocould not find a getter for... in class... exception Solution

In the Java project development process of the spring + Hibernate framework, this error is often encountered:

Cocould not find a getter for... in class...

The possible reasons are as follows:

1. There is really no getter Writing Method (occurrence probability: Small)

2. *. HMB. the attribute names and pojo in the XML file are inconsistent (*. HBM. XML and *. java is not properly connected, inconsistent), the field property is not correctly configured, for example ,*. HMB. XML *. java address should be clear (the full path of the referenced package should be clearly indicated); ing error; incorrect configuration of the generated joint primary key when multiple primary keys exist; spelling error (including multiple spaces) (occurrence probability: Large)

3. method writing error/method name writing error, which must be written in accordance with the JavaBean writing specification. Otherwise, no error can be found (high probability)

2. When data in JSON format is returned, the first character returned by struts is changed to lowercase.

3. Immediate search policy is recommended at the class level, while delayed search policy is recommended at the association level. You can use the get () method of the session instance if you do not consider the retrieval policy used at the class level and want to immediately retrieve the Persistent Object.

4,To directly use Chinese Characters in hql query statements, we must add the definition of the above attribute to the hibernate. cfg. xml configuration file:

<property name='hibernate.query.factory_class">     org.hibernate.hql.classic.ClassicQueryTranslatorFactory<property>

5. differentiate several table connections

6. Solve Chinese garbled characters

   
<property name="connection.url">jdbc:mysql://localhost:3306/db_test12?useUnicode=true&characterEncoding=gb2312</property>

7. dialect configuration in the database

MySQL Dialect: mysqldialect; SQL Server Dialect: sqlserverdialect

8. Because hibernate relies on Object Identifiers (OID) to distinguish different persistence objects. The object identifier (OID) can be generated through the built-in identification generator of hibernate.

The OID is generated by the auto-incrementing primary key mechanism of the underlying database.

Native supports automatic OID Generation Based on the underlying database. You can select the identity, sequence, or hile generator to generate an oId, which is often used across platforms.

9. cascading relationships play a very important role in hibernate. They can ensure the consistency of the operations associated with the master prosecution, for example, when the primary prosecution performs the save, update, or delete operation, the Prosecution performs the same operation.

10. The get () method of the session is used to load the specified persistent object to the session cache from the database. If the specified record does not exist, null is returned.

The load () method of the session is used to load the specified persistent object from the database to the session cache. If the specified record does not exist, an exception is thrown.

11,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.