Announcement Announcement Module
Collapse
No announcement yet.
HIbernate POJO generater Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HIbernate POJO generater

    Hi ,

    I m new to hibernate and spring . I generated the data layer code using hibernate POJO generator with mysql DB after database work is over . configured well and application was working well. But now I wanna make a slight change , changing the database name in the config file (need to connect another database consisting same structure but data different) .

    Still it was going to the old database and retaining the old data


    --------- actual config file ---------------
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property>
    <property name="url"><value>jdbc:mysql://localhost/goals</value> </property>
    <property name="username"><value>root</value></property>
    <property name="password"><value>test</value></property>
    </bean>


    -------- new config file changed database name in the URL ----------

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property>
    <property name="url"><value>jdbc:mysql://localhost/magic</value> </property>
    <property name="username"><value>root</value></property>
    <property name="password"><value>test</value></property>
    </bean>





    can anyone please help

  • #2
    What is the problem you are facing?

    Comment


    • #3
      Use the property override configurator instead (i.e. just create a properties file to override the settings you want)

      Comment


      • #4
        use org.springframework.beans.factory.config.PropertyP laceholderConfigurer bean factory post processor

        oracle.properties
        ============
        db.driverClassName=oracle.jdbc.driver.OracleDriver
        db.url=jdbc:oracle:thin:@db-server:1521:db-schema
        db.username=username
        db.password=password

        applicationcontext.xml
        =================

        <bean id="placeholderConfig" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer ">
        <property name="location"><value>Oracle.properties</value> </property>
        </bean>
        <bean id="dataSource" destroy-method="close">
        <property name="driverClassName"><value>${db.driverClassName }</value></property>
        <property name="url"><value>${db.url}</value></property>
        <property name="username"><value>${db.username}</value></property>
        <property name="password"><value>${db.password}</value></property>
        </bean>

        Comment


        • #5
          Sounds complicated!

          How about a web-based code generator that produces for you:

          - DDL statement for your DB table
          - JavaBean class to represent rows in the table
          - Full-CRUD (Create/Read/Update/Delete) JDBC DAO class
          - A full-CRUD, working web application (UI) with modern AJAX tachniques

          Basically everything you need to implement a new feature that involves a new DB table. Better than Grails, and it's all pure Java, and totally free.

          You're gonna love this, check it out here: http://www.timechannels.com/WhatIsPOJOJenerator

          John

          Comment

          Working...
          X