The performance of hibernate's Boolean judgment methods in different databases (Postgres and SQL Server2000)

Source: Internet
Author: User

Hibernate can be used to implement cross-database to a certain extent, but sometimes there are still some problems, even if it does not involve the advanced features of the database. recently, a project was developed in windwos + SQL Server2000, while the server environment is Linux + PostgreSQL. we know that in SQL Server, the boolean type is written to = 0 or 1, while in PostgreSQL, The boolean type is determined to be false or true. however, we use hibernate3 as the middleware for ing. how should we determine the Boolean Type in hql?
We can query all the unmarked and deleted tags from the database.ArticleRecord is used as an example. The first method is as follows:

Code
    1. Find ("From article as t where T. delflag = false");


This method cannot be run in SQL Server, but it can be run in PostgreSQL;
Let's look at the 2nd writing methods: Code

    1. Find ("From article as t where T. delflag = 0");


This method cannot be used in PostgreSQL, but it can be used in SQL Server2000;
3rd writing methods: Code

    1. Find ("From article as t where T. delflag =? ",False);


This method can be used in PostgreSQL and sqlserver2000.

 

The conclusion is: Do not splice strings in hql.
We also hope that the new version of hibernate will have better fault tolerance capabilities.

 

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.