MS SQL Server がカタログとスキーマの定義を必要としているのに、HSQLDB がそうではないという同じ問題に遭遇しました。私の解決策は、カタログとスキーマを設定する MS SQL Server 専用のカスタム orm.xml ファイルを (persistence.xml 経由で) ロードすることでした。
1. エンティティの @Table 名のみを指定します (カタログまたはスキーマ情報は省略します)。
@Entity
@Table(name="CATEGORY")
public static class Category { ... }
2. META-INF/persistence.xml ファイルで 2 つの永続ユニット ノードを指定します。
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<!--
| For production and integration testing we use MS SQL Server, which needs
| the catalog and schema set (see orm-mssql.xml).
|-->
<persistence-unit name="com.mycompany.prod">
<mapping-file>META-INF/orm-mssql.xml</mapping-file>
</persistence-unit>
<!--
| For unit testing we use HSQLDB, which does not need the catalog or schema.
|-->
<persistence-unit name="com.mycompany.test" />
</persistence>
3. orm-mssql.xml ファイルで既定のカタログとスキーマを指定します。
<entity-mappings version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd">
<persistence-unit-metadata>
<!--
| Set the catalog and schema for MS SQL Server
|-->
<persistence-unit-defaults>
<schema>MYSCHEMA</schema>
<catalog>MYCATALOG</catalog>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
4.Spring を使用して JPA を構成しているので、persistenceUnitName の値にプロパティ プレースホルダーを使用します。
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<property name="persistenceUnitName" value="${entityManagerFactory.persistenceUnitName}" />
</bean>
単体テストの場合は 'com.mycompany.test' を使用し、統合テスト/運用展開の場合は 'com.mycompany.prod' を使用します。