MiddleGen-Hibernate-R5 configuration
MiddleGen Hibernate configuration
Hibernate O / R mapping tool
http://internap.dl.sourceforge.net/sourceforge/hibernate/middlegen-hibernate-r5.zip
You can generate a * .hbm.xml file, is the mapping file required for Hibernate, downloading the MiddleGen Hibernate and decompressed.
Configuring the database as an example of MS SQLServer, JBDC is driven to MSSQLServer (other driver can also be connected, as long as you can connect to MS SQLServer)
1, enter / config / database / directory
2, driver MSSQLSERVER.JAR driver to / lib / directory
3, edit the mssql.xml file, as follows
Look at other articles say that the above two can be deleted or not fill, but I have the problem that the deletion or value is from the problem. Edit Middle Gen Hibernate configuration 1, edit build.xml 2, modify the default file, find this line, probably around 22 lines
// Original content, annotation // Plus ]> 3, edit the root directory name, find this line, about 30 lines // original content, annotation
Destination = "$ {build.gen-src.dir}" Package = "$ {name} .hibernate" / -> // Original content, annotation Destination = "$ {build.gen-src.dir}" Package = "$ {name} .test" /> / / Plus, in the generated XML file, will use com.test as your package Output directory is /build/gen-src/com/test/*.hbm.xml(- is a corresponding table, named the name you defined by you) 5, define the output directory, find the line, last in the document xmlvalidate> target> 6. When connecting SQL Server, prompt the database connection to success, but say no table, find the line Appname = "$ {name}" Prefsdir = "$ {src.dir}" GUI = "$ {gui}" DatabaseURL = "$ {database.URL}" InitialContextFactory = "$ {java.naming.factory.initial}" ProviderURL = "$ {java.naming.provider.URL}" DataSourcejndiname = "$ {Datasource.jndi.Name}" Driver = "$ {database.driver}" UserName = "$ {database.userid}" Password = "$ {database.password}" Schema = "$ {database.schema}" // remove Catalog = "$ {database.catalog}" // removed, so you can After testing these two lines can't be deleted, otherwise there is no table, I don't know why? ? ? > All over the configuration After the configuration is complete, run an Ant in the root directory There will be a visual operation interface, as shown The default will generate the corresponding name according to the table name and field name. Of course, you can also define it yourself, you can click [Generate], you can find it. /BUILD/Gen-src/com/test/*.hbm.xml, generates the corresponding XML file