Hibernate optimistic locking point of attention Timestamp

<timestamp name="updDate" column="UPD_DATE"></timestamp>

This must follow the definition of id

This time AP server and DB server is not time to update the database.

Update the database that is used when a new Date (), rather than sysdate.

If you are using DB server time to update the DB, you must be added the source = "db"

At this time, hibernate will remove the current time (select sysdate from dual) start with a database, and then the time is updated.

Not with sysdate update the database (update table1 set upd_date = sysdate ......) in the strict sense.

If the update results in no millisecond information, please check Dialect, should be used org.hibernate.dialect.Oracle10gDialect. (Oracle9 and later should support ms)

Do not use org.hibernate.dialect.OracleDialect, the class has been Deprecated.

After using org.hibernate.dialect.Oracle10gDialect, take time SQL DB becomes select systimestamp from dual.


Hibernate using Criteria, in addition to the default related conditions associated to add additional conditions: createAlias ​​( "xxxx", "b", Criteria.LEFT_JOIN, criteria).


<set name="MUpdateFuncTabs" table="M_UPDATE_FUNC_TAB" inverse="true" lazy="false" fetch="join">

或者criteria.setFetchMode("MUpdateFuncTabs", FetchMode.JOIN)

In general, SQL statement can execute only a primary table and the sub-data tables are taken back. But join will lead to an increase in the search results, as a result of the number of pieces number of pieces after join the ......

But if the associated side tables specified in the query criteria

criteria.createAlias("MUpdateFuncTabs", "tabs", JoinType.LEFT_OUTER_JOIN, Restrictions.eq(MUpdateFuncTab.DEL_FLG, Constant.DEL_FLG_VALID));

So, it will become fetch = "select" the same effect, will perform N SQL statements to obtain the data side tables.



Guess you like

Origin blog.csdn.net/F2004/article/details/25399485