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
- 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
- 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
- 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.