Pergunta

I am using spring-data and jpa project facet in sts to generate entities directly from my database schema. What is the best practice in managing the migration of 'annotated' entities between different environments (dev, staging, prod ..etc) .

given an entity

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

How do i migrate (only produce maven artifacts targetted to the particular environment) the above entity to

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

perhaps using spel ?

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

thanks in advance

Foi útil?

Solução

Although i have not received a final 'recommended' answer This works fine for me

    <!-- 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>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top