Question: I have spring+hibernate project, I want to write Unit test case for DAO layers,
Currently I am using HSqldb's in memory DB to test it. (I referred [this](http://howtodoinjava.com/2015/04/17/how-you-should-unit-test-dao-layer/) )

In project, IDs are provided by sequences, As I am using in-memory DB, during test sequence are not presents so it was falling, For workaround, I have created different set of hbm files without sequence(and put them test's resource folder). Is there any better way to handle this, as keeping duplicate hbm file does look good to me. Any suggestion would be appreciated

Answer: 
If you need a sequence in your test database, just create it.

Also, make sure you have the correct database dialect configured with Hibernate.

Consult the following related questions for details:

* [Syntax issue with HSQL sequence: `NEXTVAL` instead of `NEXT VALUE`](https://stackoverflow.com/questions/21190876/syntax-issue-with-hsql-sequence-nextval-instead-of-next-value)
* [SequenceGenerator problem with unit testing in Hsqldb/H2](https://stackoverflow.com/questions/7473131/sequencegenerator-problem-with-unit-testing-in-hsqldb-h2)
* ["correct" way to select next sequence value in HSQLDB 2.0.0-rc8](https://stackoverflow.com/questions/2340037/correct-way-to-select-next-sequence-value-in-hsqldb-2-0-0-rc8)
Holding complete copies of the HBM files doesn't sound like a good idea (one of the principles I strongly believe in is [the "DRY" principle](http://en.wikipedia.org/wiki/Don't_repeat_yourself)). 
The solution I'd suggest (unless there's a better solution from the Hibernate side) is to edit the HBM file in the "@before" method, in order to change just the different bits. 
I'm more of a .Net guy, and I know that in In .Net there's a library called [FluentNHibernate](http://www.fluentnhibernate.org/) that allows the generate (and I assume that also edit existing) hbm at runtime. I'm not sure if there's something similar in Java, but you can also fallback for manipulating the hbm as an XML file.