Announcement Announcement Module
No announcement yet.
Can JPA Annotation prop value support placeholder Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can JPA Annotation prop value support placeholder

    Web all know Spring xml conf file support the prop placeholder,just like :

    <contextroperty-placeholder location="" />.
    <bean id="test" class="">
    <property name="prop1" value="${my.prop1}">

    I use the Hibernate orm and use jpa annotion to conf the entity bean,just like :

    public class Employee implements Serializable {

    In the example ,all the JPA annotion's prop must be plain string,so my question is coming :
    the table's schema is not static,it can be change in the delpoyment stage,
    So I holp the schema prop be setten like this:

    public class Employee implements Serializable {

    the ${user_bask_sys} reference to a out prop file.

    But as I know ,the hibernate engine can't support this style conf,I Know can Spring's org.springframework.orm.hibernate.annotation.Annot ationSessionFactoryBean
    dosen't support this style ?

    So my question is can I support this placeholder annotion style throngh extend the AnnotationSessionFactoryBean myself.

    can anybody tell me can I get it and how can I get it,thanks a lot !!!

  • #2
    It isn't going to work, neither with plain hibenate or with spring. You cannot replace placeholders at runtime in compiled classes...

    You can however set the default.schema property with a placeholder.

    <bean id="sessionFactory" class="LocalSessionFactoryBean">
     .. other properties ..
     <property name="hibernateProperties">


    • #3
      to Marten Deinum

      thank you for your reply!!

      If the app only has one db schema,your approach will be work.but my app

      has more than one db schema,all the schema names must be configurable,

      so the default schema property of hibernate get into trouble.


      • #4

        Hi, I have a similar situation where I need to externalize the schema name used in the @Table annotation. Did you ever resolve this?