1

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

sunny
  • 824
  • 1
  • 14
  • 36
  • from [_here_](http://stackoverflow.com/questions/2737420/how-to-set-up-default-schema-name-in-jpa-configuration) i have figured out the property to set the schema name independent of the annotations. – sunny May 01 '12 at 18:14
  • ok i believe i have this working by setting the hibernate.default_schema property for the jpaproperties while configuring the entitymnanagerfactory from spring – sunny May 01 '12 at 18:24

1 Answers1

0

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>
sunny
  • 824
  • 1
  • 14
  • 36