-
Feb 5th, 2011, 04:11 AM
#1
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
-
Feb 5th, 2011, 04:45 AM
#2
What is the problem you are facing?
Amila Domingo
-
Feb 8th, 2011, 05:11 AM
#3
Use the property override configurator instead (i.e. just create a properties file to override the settings you want)
-
Feb 9th, 2011, 03:16 AM
#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>
-
Mar 9th, 2011, 01:02 PM
#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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules