Pitfall on these days

Source: Internet
Author: User

There are many open-source benefits, which lowers the barrier for us to access high-end products in the industry and simplifies the development complexity to a certain extent. However, it also brings many problems, the use of open source means that you have to bear the consequences of its instability. Looking back at the pitfalls that have been put on these days, they are all tears... Fortunately, I am not using it alone, but I can use Google more.

I will not commit any mistakes in the future:

Hibernate can use xml configuration to automatically generate tables by classes. After SSH is used, it will not work with the original configuration. It turns out that I am in <prop key = "hibernate. hbm2ddl. auto "> Create </prop> is not caused by the addition of hibernate. After the addition, the table cannot be automatically created through update until it is changed to create. It took a lot of time to find this error, this should be a spring bug.

<Property name = "hibernateproperties">
<Props>
<Prop key = "hibernate. dialect"> org. hibernate. dialect. mysqldialect </prop>
<Prop key = "hibernate. show_ SQL"> true </prop>
<Prop key = "hibernate. format_ SQL"> true </prop>
<Prop key = "hibernate. hbm2ddl. Auto"> Create </prop>
</Props>
</Property>

In some database operations, there are also a lot of pitfalls listed below, especially the third, which will only be integrated for a whole night and will not be committed in the future.

Exception 1: Not-NullProperty referencesNullOrTransientValue
Solution: Set "one" in the "one-to-many" relationship,Not-NullSetFalse

Exception 2: org. hibernate. transientobjectexception: Object references an unsaved transient instance
Solution:Cascade = "Save-Update, persist"

Exception 3: org. hibernate. queryexception: cocould not resolve property
Solution: "From category where category. userid =: userid "changed to" from category whereuserid =: userid "or" from category where category. user. id =: userid"

exception 4: cocould not initialize proxy-the owning session was closed
solution: set lazy to false

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.