Auto Generate hibernate mapping files and pojos

Use the following targets to auto generate hibernate mapping files from database and pojos from .hbm.xml files.

<taskdef name=”hbm2java”
classname=”net.sf.hibernate.tool.hbm2java.Hbm2JavaTask”>
<classpath refid=”hbm2java.class.path” />
</taskdef>

<taskdef name=”middlegen” classname=”middlegen.MiddlegenTask”>
<classpath refid=”middlegen.class.path” />
</taskdef>

<target name=”hbm2java” description=”Generate Java Pojos from the Hibernate mapping files”>
<hbm2java output=”${source.generated}”
config=”hibernate.cfg.xml”>
<fileset dir=”${hibernate.source}”>
<include name=”**/*.hbm.xml” />
</fileset>
</hbm2java>
</target>

<target name=”middlegen” description=”Generate Hibernate mapping files”>
<middlegen appname=”Hibernate-Spring” prefsdir=”${middlegen.temp}”
gui=”false” databaseurl=”${jdbc.url}” driver=”${jdbc.driver}”
username=”${database.username}” password=”${database.password}”
schema=”${database.schema}” catalog=”${database.catalog}”>
<!– Optionally declare table elements –>
<!– Optionally declare many2many elements –>
<!– One or more plugins –>
<hibernate destination=”${source.generated}”
package=”${package.name}”
javaTypeMapper=”middlegen.plugins.hibernate.HibernateJavaTypeMapper” />
</middlegen>
</target>

Sample build.properties file

# MSJava, Hibernate, Middlegen
hibernate.home=C:/Hibernate/hibernate-2.1
hibernate.extensions.home=C:/Hibernate/hibernate-extensions-2.1.3
middlegen.home=C:/Hibernate/middlegen-2.1
middlegen.temp=C:/middlegen.temp

# Source Folders/Packages
source.generated=packages
hibernate.source=packages/java/test
package.name=java.test

# Database connection
jdbc.url=
jdbc.driver=
database.username=
database.password=
database.schema=
database.catalog=

I hope that helps, Cheers Bye

Comments

start stop tomcat with ant

Here is a simple ant target to start/stop your instance of tomcat running

<target name=”start-tomcat”>
<if>
<not>
<http url=”http://localhost:8080″ />
</not>
<then>
<java jar=”${tomcat.home}/bin/bootstrap.jar” fork=”true”>
<jvmarg value=”-Dcatalina.home=${tomcat.home}” />
</java>
<echo message=”Server Started”></echo>
</then>
<else>
<echo message=”Tomcat Instance Already Running”></echo>
</else>
</if>
</target>

<target name=”stop-tomcat”>
<if>
<http url=”http://localhost:8080″ />
<then>
<java jar=”${tomcat.home}/bin/bootstrap.jar” fork=”true”>
<jvmarg value=”-Dcatalina.home=${tomcat.home}” />
<arg line=”stop” />
</java>
<echo message=”Server Terminated”></echo>
</then>
<else>
<echo message=”No Tomcat Instance Running”></echo>
</else>
</if>
</target>

These targets would first check to see if any instance of tomcat is running or not else would initiate the process

Conditions:

  • your tomcat.home variable is set
  • server runs on localhost:8080

Comments

What is a Data Service

A Data Service is about exposing data through Services. Data Services provides abstarcted and consolidated view of data between the consumer and diverse data source kinds. Data services are like virtual datasouces, consuming data from different sources and providing a complex view of data according to our needs. Data Services simplfies our data access by providing multiple ways of data access like web services, java clients, mediator api (SDO), etc. They once created are highly reusable across different applications. They highly simplfy the development process by eliminating the need to write any code but providing a graphical enviroment to generate the code.

Comments

What in Aqualogic DSP?

Yup! here are some points to look into when driving your feet into Data Services Platform Domain.

  • What is DSP?
  • Why DSP?
  • What is a Data Service?
  • The Installation.
  • Dataspace Project & Components.
  • Importing datasource metadata.
  • Using design view - Creating logical components
  • Using source view - Writing Xquery
  • XQuery Basics
  • Testing and Viewing query plan
  • Updating Metadata
  • Catches and Tricks

Would be soon coming up on each topic…!

Comments

Why Aqualogic Service Bus (ALSB)

Aqualogic Service Bus is a great product for development of SOA Services. It help us achieve dynamic routing, message processing, Exception Handling, Message Validations, blah blah blah…So lets get actually to the point where we say why actually we need that.

Over the years, Service Oriented Architecture (SOA) has come up as a “big tag” with in the Industry. What we see is, that, our Business requirements have grown many folds & so has the time to deliver those requirements decreased. SOA can help our business respond to these fast paced market needs quickly. BEA Aqualogic SB promises to make that happen. BEA ALSB accelerates the development and deployment of services. It simplifies the management of shared services across SOA. It promises to provide us with great message routing capabilities, support for multiple endpoints & transports, security, monitoring & auditing & message transformation capabilities.

Comments

Why Aqualogic Data Services Platform(DSP)?

BEA Aqualogic Data Services Platform (ALDSP), is a tool that can help you write data services. But wait.. what the hell is this data service? Well the concept is simple, why not expose data itself as a service.
Aldsp comes with some great features like ability to connect to different data sources like relational databases, xml files, services, java functions, delimited files all together together with great efficiency to get its data. The concept of data services is extended further as Physical & Logical DS. Physical DS are those which are created automatically when a data source metadata is imported. Such physical DS would thus expose functions that would enable us to get / insert / delete / update data in the underlying actual source. However that certainly is not enough when it comes to real life scenarios where we need data from different souces collated together in a logical format. Here comes the logical DS and the real beauty of DSP. Logical data services are those which we create and write logic that talks to different physical ds to output the data in a format which we want. But you don’t have to write a single piece of code to do that. DSP provides a graphical interface (known as query map) where we can drag and drop physical ds functions, graphically pass values, map input to output and thats all done! DSP automatically generates code in the background in xquery language. However as the logic gets more and more complex, the graphical way may not seem to be an easy way to continue. In that case its good to switch to xquery source and write some code….DSP also uses an internal XQuery optimizer to make the generated SQL highly optimized.
Hope that would help you.!!! contact me if you have some doubts with DSP. And do try it since its really good. Wait for my next post for a simple example on DSP and also a quick look into DSP.

Comments