【问题标题】:Moving annotated jpa entities between environments在环境之间移动带注释的 jpa 实体
【发布时间】:2012-05-11 04:15:58
【问题描述】:

我在 sts 中使用 spring-data 和 jpa 项目方面直接从我的数据库模式生成实体。管理“注释”实体在不同环境(开发、登台、产品等)之间迁移的最佳实践是什么?

给定一个实体

@Entity
@Table(name="DevEnvironment.dbo.mytable")
public class MyTable implements Serializable {}

我如何将上述实体迁移(仅生成针对特定环境的 maven 工件)到

@Entity
@Table(name="ProdEnvironment.dbo.mytable")
public class MyTable implements Serializable {}

也许使用 spel ?

环境 spring-data-jpa, spring3.1.0 , o.s.o.j.v.HibernateJpaVendorAdapter

提前致谢

【问题讨论】:

  • 来自here 我已经找到了设置独立于注释的架构名称的属性。
  • 好的,我相信我可以通过设置 jpaproperties 的 hibernate.default_schema 属性,同时从 spring 配置 entitymnanagerfactory

标签: hibernate-annotations spring-annotations spring-data-jpa


【解决方案1】:

虽然我还没有收到最终的“推荐”答案 这对我来说很好用

    <!-- entity manager -->
<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="myDataSource" />
    <property name="jpaVendorAdapter" ref="jpaAdapter" />
    <property name="persistenceUnitName" value="mypu" />
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.default_schema">${default_schema}</prop>
        </props>
    </property>
</bean>

【讨论】:

    猜你喜欢
    • 2013-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-21
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    相关资源
    最近更新 更多