본문 바로가기

Programing/닷넷

[NHibernate] 현재 시간 current_timestamp

DB 마다 시간 구하는 함수가 다르다.


하이버네이트에서는 방언(dialect)라는 개념을 이용해서 쿼리를 변환해주는 기능이 있는데,

보니 current_timestamp를 괄호없이 사용하면 된다.

eg)

<sql-query name="Mappings.DeviceMap.Update">

    UPDATE sdh2k_device_map

      SET sdh2000_ip = :sdh2000IP, updated_datetime = current_timestamp

      WHERE mfp_ip = :mfpIP;

</sql-query>


구현은 아래 URL을 참고

MsSqlServer : https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/MsSql2000Dialect.cs

 (current_timestamp -> getdate)


PostgreSQL : https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/PostgreSQLDialect.cs

 (current_timestamp -> now)


MySQL : https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/Dialect.cs (inherited Dialect)

 current_timestamp -> current_timestamp

 

Oracle : https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Dialect/Oracle8iDialect.cs

 current_timestamp -> current_timestamp