0

I have a mapping that retrieves all active roles for a user. I use the where attribute to filter out roles in the hbm mapping. The mapping look like this:

<map name="Bar" table="Foo_Bar" lazy="true" cascade="all" inverse="false" where="intGroupId Is Null And dtmExpires > getdate()">
<cache usage="read-write"/>
<key column="intUserId"/>
<index column="varRole" type="string"/>
<one-to-many class="Foo.Bar, Foo"/>
</map>

This works great in production on a SQL Server, but in my unit tests where I use SQLite the getdate() function isn't recognized.

How can I modify my mapping so it works in both MS SQL Server and SQLite, but still have the filter?

// Johan

1 Answer 1

1

I don't know much about SQLite but you may be able to use

intGroupId Is Null And dtmExpires > CURRENT_TIMESTAMP

CURRENT_TIMESTAMP is the SQL Standard equivalent of getdate(), and I believe it is implemented in SQLite (and I'm positive it is in SQL Server).

You may be able to use the technique discussed here to tweak your mappings at runtime if this doesn't work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.