From jbosstools-commits at lists.jboss.org Wed Mar 2 18:34:48 2011 Content-Type: multipart/mixed; boundary="===============5725373306654171274==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r29455 - in trunk/hibernatetools/docs/reference/en-US: images/plugins and 1 other directory. Date: Wed, 02 Mar 2011 18:34:48 -0500 Message-ID: <201103022334.p22NYmFE002018@svn01.web.mwc.hst.phx2.redhat.com> --===============5725373306654171274== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mcaspers Date: 2011-03-02 18:34:47 -0500 (Wed, 02 Mar 2011) New Revision: 29455 Removed: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml trunk/hibernatetools/docs/reference/en-US/master.xml trunk/hibernatetools/docs/reference/en-US/master_output.xml Modified: trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0_a.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_0_b.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_1.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_2.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_2_a.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_3.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_a.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_b.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_c.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_4_d.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_5.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_6.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_7.png trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_8.png trunk/hibernatetools/docs/reference/en-US/introduction.xml trunk/hibernatetools/docs/reference/en-US/plugins.xml Log: updated images and general editing Modified: trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml 2011-= 03-02 22:58:02 UTC (rev 29454) +++ trunk/hibernatetools/docs/reference/en-US/codegenarchitecture.xml 2011-= 03-02 23:34:47 UTC (rev 29455) @@ -3,36 +3,36 @@ Code generation architecture = - The code generation mechanism in Hibernate Tools consists of a few core concepts. This section explains their overall st= ructure, which are the same for the Ant and Eclipse tools. + The code generation mechanism in Hibernate Tools consists of a few core concepts. This section explains their overall st= ructure, which is the same for the Ant and Eclipse tools. =
Hibernate Meta Model = - The meta model is the model used by Hibernate Core to perform its object relational mapping. The model includes informa= tion about tables, columns, classes, properties, components, values, collec= tions etc. The API is in the org.hibernate.mapping package and= its main entry point is the Configuration class, the same cla= ss that is used to build a session factory. + The meta model is the model used by Hibernate Core to perform its object relational mapping. The model includes informa= tion about tables, columns, classes, properties, components, values, collec= tions etc. The API is in the org.hibernate.mapping package and= its main entry point is the Configuration class: the same cla= ss that is used to build a session factory. = - The model represented by the Configuration class can be bu= ilt in many ways, which are listed below. + The model represented by the Configuration class can be bu= ilt in many ways: = - A Core configuration uses Hibernate Core = and supports reading hbm.xml files, and requires a hibernate.cfg.xml file. This is referred to as core in Eclipse and <configuration> in = Ant. + A Core configuration uses Hibernate Core = and supports reading hbm.xml files, and requires a hibernate.cfg.xml file. This is referred to as = Core in Eclipse and <configuration> in Ant. = - An Annotation configuration uses Hibernate Annotations<= /productname> and supports hbm.xml files and annotated= classes, and requires a hibernate.cfg.xml file. This = is referred to as annotations in Eclipse and <annotationconfiguration> in Ant. + An Annotation configuration uses Hibernate Annotations<= /productname>, supports hbm.xml files and annotated cl= asses, and requires a hibernate.cfg.xml file. This is = referred to as Annotations in Eclipse and <an= notationconfiguration> in Ant. = - A JPA configuration uses a Hibernate EntityManager and supports hbm.xml files and annotated cla= sses, and requires that the project has a META-INF/persistence.xm= l file in its classpath. This is referred to as JPA= in Eclipse and <jpaconfiguration> in Ant.= + A JPA configuration uses a Hibernate EntityManager and supports hbm.xml files and annotated cla= sses, and requires that the project has a META-INF/persistence.xm= l file in its classpath. This is referred to as JPA in Eclipse and <jpaconfiguration> in Ant. = @@ -43,12 +43,12 @@ = - In most projects you will normally use only one of the Core, Annotation= or JPA configuration and possibly the JDBC configuration if you are using = the reverse engineering facilities of Hibernate Tools. = + In most projects you will normally use only one of the Core, Annotation or JPA conf= iguration and possibly the JDBC configuration if you are using the reverse = engineering facilities of Hibernate Tools. = = Note: - No matter which Hibernate Configuration type you are using Hibernate Tools supports them. + Hibernate Tools has support for all kinds of Hibernate Configurat= ions. = The following drawing illustrates the core concepts: @@ -78,15 +78,15 @@ Exporters = - Code generation is done in so called Exporters. An Exporter is handed a Hibernate Meta Model represented as a Configuration instance and it is then the job of the exporter to generate a set of co= de artifacts. + Code generation is performed by an Exporters. An Exporter is handed a Hibernate Meta Model represented as a Configurati= on instance, and it is then the job of the exporter to generate a se= t of code artifacts. = - The tools provides a default set of Exporter's which can be used in bot= h Ant and the Eclipse UI. Documentation for these Exporters is in and . + The tool provides a default set of Exporter's which can be used in both= Ant and the Eclipse UI. Documentation for these Exporters can be found in = and . = - Users can provide their own custom Exporter's, either through custom cl= asses implementing the Exporter interface or simply be providing custom tem= plates. This is documented at in . + Users can provide their own custom Exporter's, either through custom cl= asses implementing the Exporter interface or simply through cu= stom templates. This is documented at in .
Deleted: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.x= ml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml 20= 11-03-02 22:58:02 UTC (rev 29454) +++ trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins.xml 20= 11-03-02 23:34:47 UTC (rev 29455) @@ -1,2564 +0,0 @@ -=EF=BB=BF - - Eclipse Plugins - This chapter will introduce you to the functionality that Hibernate - Tools provide within Eclipse. That is a set of wizards an= d editors for simplifying - the work with Hibernate. -
- Introduction - Hibernate Eclipse Tools include wizards for creating Hibernate m= apping files, - configuration files (.cfg.xml), revenge.xml as well as wizards for a= djusting Console - Configuration and Code Generation. Special structured and XML editor= s, editors for executing - HQL and Criteria queries are also provided in Hibernate Console. Ref= er to section to find all benefits = that you - can take advantage of while using the tools within Eclipse. - - Note: - Please note that these tools do not try to hide any functional= ity of Hibernate. The tools make working with Hib= ernate easier, - but you are still encouraged/required to read the Hibernate Documentation<= /ulink> to fully utilize - Hibernate Tools and especially Hi= bernate it - self. - -
-
- Creating a Hibernate Mapping File - Hibernate mapping files are used to specify how your objects are= related to database - tables. - To create basic mappings for properties and associations, i. e. = generate - .hbm.xml - files, Hibernate Tools provide a basic wizard which you = can bring up by navigating - - New > Hibernate XML mapping file.<= /para> - At first you'll be asked to select a package or multiple in= dividual classes to map. - It's also possible to create an empty file, don't select any pa= ckages or classes and an - empty .hbm will be created in the specified location - With depth control opt= ion you can define dependences depth for - choosing classes (it means to set level of references which is used = to collect linked classes - to the selection). -
- Hibernate XML Mapping File Wizard - - - - - -
- The next wizard page lists the mappings to be generated. As you = see Customers, Orders, = Productlines and Products classes added und= er depth control driving. -
- Mappings to be generated - - - - - -
- = - This wizard page outputs a generated .hbm files preview. -
- Preview Generated Mapping Files - - - - - -
- Pressing Finish creates the files. -
-
- Creating a Hibernate Configuration File - To be able to reverse engineer, prototype queries, and of course= to simply use Hibernate Core a - hibernate.properties - or - hibernate.cfg.xml - file is needed. The Hibernate Tools= provide a wizard for - generating the - hibernate.cfg.xml - file if you do not already have such one. - Start the wizard by clicking - New > Other (Ctrl+N) - , then - Hibernate > Hibernate Configuration File (cfg.xml) - and press - Next - or on a web Seam project in the Web Projects view - WebContent -> New -> File -> Hibernate Configuration 3.= 0 - . After selecting the wanted location for the - hibernate.cfg.xml - file, you will see the following page: -
- Hibernate Configuration File Wizard - - - - - - - - -
- - Note: - The contents in the combo boxes for the JDBC driver class and = JDBC URL change - automatically, depending on the Dialect and actual driver you have= chosen. - - Enter your configuration information in this dialog. Details abo= ut the configuration - options can be found in Hibernate - Reference Documentation. - Press - Finish - to create the configuration file, after optionally creat= ing a Console - configuration, the - hibernate.cfg.xml - will be automatically opened in an editor. The last opti= on - Create Console Configuration - is enabled by default and when enabled, it will automati= cally use the - hibernate.cfg.xml - for the basis of a Console configuration. -
-
- Hibernate Console Configuration - A Console configuration describes how the Hibernate pl= ugin should - configure Hibernate and what configuration file= s, including which - classpath are needed to load the POJO's, JDBC drivers etc. It is req= uired to make usage of - query prototyping, reverse engineering and code generation. You can = have multiple named - console configurations. Normally you would just need one per project= , but more is definitely - possible if your project requires this. -
- Creating a Hibernate Console Configuration - You create a console configuration by running the Co= nsole Configuration - Wizard, shown in the following screenshot. The same w= izard will also be used if - you are coming from the - hibernate.cfg.xml - wizard and had enabled - Create Console Configuration - . - - Note: - The wizard will look at the current selection in the IDE and= try and auto-detect the - settings which you then can just approve or modify to suit your = needs. - - - The dialog consists of five tabs: - - - - Main - for the basic/required settings - - -
- Creating Hibernate Console Configuration - - - - - - - - -
- The following table describes the available settings on the - Main - tab. The wizard can automatically detect default value= s for most of these if you - started the wizard with the relevant java project or resource sele= cted. - - Hibernate Console Configuration Parameters - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Name - - - The unique name of the console configuration - - - Name of the selected project - - - - - Type - - - Choose between "Core", "Annotations&q= uot; and "JPA". - Note that the two latter requires running Eclipse IDE wi= th a JDK 5 runtime, - otherwise you will get classloading and/or version error= s. - - - No default value - - - - - Project - - - The name of a java project which classpath should be= used in the console - configuration - - - Name of the selected project - - - - - Database connection - - - DTP provided connection that you can use instead of = what is in cfg.xml and jpa - persistence.xml. It's possible to use either alread= y configured hibernate or - JPA connection or specify a new one here. - - - [Hibernate Configured connection] - - - - - Property file - - - Path to a hibernate.properties file - - - First hibernate.properties file found in the selecte= d project - - - - - Configuration file - - - Path to a hibernate.cfg.xml file - - - First hibernate.cfg.xml file found in the selected p= roject - - - - - Persistence unit - - - Name of the persistence unit to use - - - No default value (lets Hibernate Entity Manager find= the persistence unit or - it can be defined manually using Browse button) - - - - -
- - Tip: - The two latter settings are normally not required if you spe= cify a project and it has - - - /hibernate.cfg.xml - - or - - /META-INF/persistence.xml - - in its project classpath. - - - - - - Options - for the additional/optional settings - - -
- Options Tab of the Console Configuration Wizard - - - - - -
- The next table describes Hibernate Console Configuration optio= ns available on the - - Options - tab. - - Hibernate Console Configuration Options - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Database dialect - - - Define a database dialect. It's possible either= to write your value or choose - from list. - - - No default value - - - - - Naming strategy - - - Fully qualified classname of a custom NamingStrategy= . Only required if you use - a special naming strategy. - - - No default value - - - - - Entity resolver - - - Fully qualified classname of a custom EntityResolver= . Only required if you - have special xml entity includes in your mapping files.<= /para> - - - No default value - - - - -
- - - - Classpath - for classpath - - -
- Specifying Classpath in Hibernate Console Configuration</ti= tle> - <mediaobject> - <imageobject role=3D"fo"> - <imagedata align=3D"center" fileref=3D"images/plugins/plugins_= 3.png" format=3D"PNG"/> - </imageobject> - <imageobject role=3D"html"> - <imagedata align=3D"center" fileref=3D"images/plugins/plugins_= 3.png" format=3D"PNG"/> - </imageobject> - </mediaobject> - </figure> - <para>The following table specifies the parameters of the Classpath = tab of the wizard.</para> - <table> - <title>Hibernate Console Configuration Classpath - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Classpath - - - The classpath for loading POJO and JDBC drivers; onl= y needed if the default - classpath of the Project does not contain the required c= lasses. Do not add - Hibernate core libraries or dependencies, they are alrea= dy included. If you get - ClassNotFound errors then check this list for possible m= issing or redundant - directories/jars. - - - Empty - - - - - Include default classpath from project - - - When enabled the project classpath will be appended = to the classpath specified - above - - - Enabled - - - - - - - - - Mappings - for additional mappings - - -
- Specifying additional Mappings in Hibernate Console Configu= ration - - - - - - - - -
- Parameters of the Mappings tab of the Hibernate Cons= ole Configuration - wizard are explained below: - - Hibernate Console Configuration Mappings - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Mapping files - - - List of additional mapping files that should be load= ed. Note: A - hibernate.cfg.xml or persistence.xml can also contain ma= ppings. Thus if these are - duplicated here, you will get "Duplicate mapping" errors= when using the console - configuration. - - - empty - - - - -
- - - and the last tab - Common - - - -
- Common Tab of the Console Configuration Wizard - - - - - -
- It allows to define general aspects of the launch configuratio= n including storage - location, console encoding and some others. - Clicking - Finish - creates the configuration and shows it in the Hibernate Configurations - view. -
- Console Overview - - - - - - - - -
-
-
- Modifying a Hibernate Console Configuration - When you created a hibernate console configuration you can mod= ify it in 2 ways: - - - right click on the configuration in - Hibernate Configurations View->Edit Configuration = - or just double click on Console Configur= ation item. -
- Opening Edit Configuration Wizard - - - - - -
- After clicking you will see the Edit Configuration Wizard= that is similar to - - Create Console Configuration - ,described in . -
- - use Properties view for modifying some of Console Configur= ation properties. -
- Properties View - - - - - -
- The following table describes the available settings in th= e Properties view. Most - properties are changeable by left click but some are not. - Properties - - - - - - - - Property - - - Description - - - Is Changeable - - - - - - - Additional mapping files - - - List of additional mapping files that should b= e loaded. - - - False - - - - - Configuration file - - - Path to a hibernate.cfg.xml file - - - False - - - - - Connection - - - DTP provided connection that you can use inste= ad of what is in cfg.xml - and jpa persistence.xml. It's possible to use= either already configured - hibernate or JPA connection or specify a new one h= ere. - - - True - - - - - Name - - - The unique name of the console configuration - - - True - - - - - Project - - - The name of a java project which classpath sho= uld be used in the console - configuration - - - True - - - - - Properties file - - - Path to a hibernate.properties file - - - False - - - - - Type - - - Choose between "CORE", "ANNOTAT= IONS" and - "JPA" according to the method of relatio= nal mapping you want to - use. Note that the two latter requires running Ecl= ipse IDE with a JDK 5 - runtime, otherwise you will get classloading and/o= r version errors. - - - True - - - - - -
-
-
-
- Closing Hibernate Console Configuration - To close Hibernate Console Configuration = you need do right click your configuration - and choose Close Configuration option -
- Close Hibernate Console Configuration - - - - - -
- While closing configuration the connection with database will = be closed, jar libs will - be unlock (for Windows) and other resources will set as free. -
-
-
- Reverse Engineering and Code Generation - A "click-and-generate" reverse engineering and code ge= neration facility is - available. This facility allows you to generate a range of artifacts= based on database or an - already existing Hibernate configuration, be that mapping files or a= nnotated classes. Some of - these are POJO Java source file, Hibernate - .hbm.xml - , - hibernate.cfg.xml - generation and schema documentation. - To start working with this process, start the Hibernat= e Code - Generation which is available in the toolbar via the Hibernate icon or via the - Run > Hibernate Code Generation - menu item. -
- Code Generation Launcher - When you click on - Open Hibernate Code Generation Dialog... - the standard Eclipse launcher dialog will appear. In t= his dialog you can create, - edit and delete named Hibernate code generation "launchers". -
- Getting Hibernate Code Generation Wizard - - - - - - - - -
- -
- Hibernate Code Generation Wizard - - - - - - - - -
- The first time you create a code generation launcher you shoul= d give it a meaningful - name, otherwise the default prefix - New_Generation - will be used. - - Tip: - The "At least one exporter option must be selected"= ; is just a warning - stating that for this launch to work you need to select an expor= ter on the Exporter tab. - When an exporter has been selected the warning will disappear. - - The dialog also have the standard tabs - Refresh - and - Common - that can be used to configure which directories should= be automatically - refreshed and various general settings launchers, such as saving t= hem in a project for - sharing the launcher within a team. - On the - Main - tab you see the following fields: - - Code generation "Main" tab fields - - - - - - - - Field - - - Description - - - - - - - Console Configuration - - - The name of the console configuration which should b= e used when code - generating - - - - - Output directory - - - Path to a directory where all output will be written= by default. It's possible - to enter absolute directory path, for example - "d:/temp= ". Be aware that existing - files will be overwritten, so be sure to specify the cor= rect directory. - - - - - Reverse engineer from JDBC Connection - - - If enabled, the tools will reverse engineer the data= base available via the - connection information in the selected Hibernate Console= Configuration and - generate code based on the database schema. If not enabl= ed, the code generation - will just be based on the mappings already specified in = the Hibernate Console - configuration. - - - - - Package - - - The package name here is used as the default package= name for any entities - found when reverse engineering - - - - - reveng.xml - - - Path to a reveng.xml file. A reveng.xml file allows = you to control certain - aspects of the reverse engineering. e.g. how jdbc types = are mapped to hibernate - types and especially important which tables are included= /excluded from the - process. Clicking "setup" allows you to select an existi= ng reveng.xml file or - create a new one. See more details about the reveng.xml = file in . - - - - - reveng. strategy - - - If reveng.xml does not provide enough customization = you can provide your own - implementation of an ReverseEngineeringStrategy. The cla= ss needs to be in the - classpath of the Console Configuration, otherwise you wi= ll get class not found - exceptions. See for details and an - example of a custom strategy. - - - - - Generate basic typed composite ids - - - A table that has a multi-column primary key a <co= mposite-id> mapping - will always be created. If this option is enabled and th= ere are matching - foreign-keys each key column is still considered a 'basi= c' scalar (string, long, - etc.) instead of a reference to an entity. If you disabl= e this option a - <key-many-to-one> instead. Note: a - <many-to-one> property is still cre= ated, but is simply marked - as non-updatable and non-insertable. - - - - - Detect optimistic lock columns - - - Automatically detect optimistic lock columns. Contro= llable via reveng. - strategy; the current default is to use columns named VE= RSION or TIMESTAMP. - - - - - Detect many-to-many tables - - - Automatically detect many-to-many tables. Controllab= le via reveng. - strategy. - - - - - Detect one-to-one associations - - - Reverse engineering detects one-to-one associations= via primary key and both - hbm.xml and annotation generation generates the proper c= ode for it. - The detection is enabled by default (except for Sea= m 1.2 and Seam 2.0) - reverse engineering. For Hibernate Tools generation ther= e is a checkbox to disable - if not wanted. - - - - - Use custom templates - - - If enabled, the Template directory will be searched = first when looking up the - templates, allowing you to redefine how the individual t= emplates process the - hibernate mapping model. - - - - - Template directory - - - A path to a directory with custom templates - - - - -
-
-
- Exporters - The - Exporters - tab is used to specify which type of code that should = be generated. Each - selection represents an Exporter that is responsible for generatin= g the code, hence the - name. -
- Selecting Exporters - - - - - - - - -
- The following table describes in short the various exporters. = Remember you can - add/remove any Exporters depending on your needs. - - Code generation "Exporter" tab fields - - - - - - - Field - - - Description - - - - - - - Domain code - - - Generates POJO's for all the persistent classes and = components found in the - given Hibernate configuration. - - - - - DAO code - - - Generates a set of DAO's for each entity found. - - - - - Hibernate XML Mappings - - - Generate mapping (hbm.xml) files for each entity. - - - - - Hibernate XML Configuration - - - Generate a hibernate.cfg.xml file. Used to keep the = hibernate.cfg.xml update - with any new found mapping files. - - - - - Schema Documentation (.html) - - - Generates a set of html pages that documents the dat= abase schema and some of - the mappings. - - - - - Generic Exporter (hbmtemplate) - - - Fully customizable exporter which can be used to per= form custom - generation. - - - - - Schema Export (.ddl) - - - Generates the appropriate SQL DDL and allows you to = store the result in a file - or export it directly to the database. - - - - -
- Each Exporter listens to certain properties and these can be s= etup in the - Properties - section where you can add/remove predefined or custome= r properties for each of - the exporters. The following table lists the time of writing prede= fined properties: - - - Exporter Properties - - - - - - - Name - - - Description - - - - - - - jdk5 - - - Generate Java 5 syntax - - - - - ejb3 - - - Generate EJB 3 annotations - - - - - for_each - - - Specifies for which type of model elements the exp= orter should create a file - and run through the templates. Possible values are: en= tity, component, - configuration - - - - - template_path - - - Custom template directory for this specific export= er. You can use Eclipse - variables. - - - - - template_name - - - Name for template relative to the template path - - - - - outputdir - - - Custom output directory for this specific exporter= . You can use Eclipse - variables. - - - - - file_pattern - - - Pattern to use for the generated files, relatively= for the output dir. - Example: {package-name}/{class-name}.java . - - - - - dot.executable - - - Executable to run GraphViz (only relevant, but opt= ional for Schema - documentation) - - - - - drop - - - Output will contain drop statements for the tables= , indices and - constraints - - - - - delimiter - - - If specified the statements will be dumped to this= file - - - - - create - - - Output will contain create statements for the tabl= es, indices and - constraints - - - - - scriptToConsole - - - The script will be output to Console - - - - - exportToDatabase - - - Executes the generated statements against the data= base - - - - - outputFileName - - - If specified the statements will be dumped to this= file - - - - - haltOnError - - - Halts the build process if an error occurs - - - - - format - - - Applies basic formatting to the statements - - - - - schemaUpdate - - - Updates a schema - - - - -
-
- To add a property to the chosen Exporter click the - Add - button in the Properties section.= In the appeared dialog - you should select the property from the proposed list and the valu= e for it. -
- Adding the Property for Schema Export (.ddl) - - - - - -
- - Tip: - If the property is a directory, it is possible to browse dir= ectories in the Value - field. - -
- Specifying the Property Value - - - - - -
-
-
-
- Hibernate Mapping and Configuration File Editor - The Hibernate Mapping File editor provides = XML editing functionality - for the - hbm.xml - and - cfg.xml - files. The editor is based on the Eclipse WTP tools and = extends its functionality - to provide Hibernate specific code completion. -
- XML Editing Functionality - - - - - - - - -
-
- Java property/class completion - Package, class, and field completion is enabled for relevant X= ML attributes. The - auto-completion detects its context and limits the completion for = e.g. - <property> and only shows the properties/fiel= ds available in the - enclosing <class> , <subclass> etc. It is also - possible to navigate from the - hbm.xml - files to the relevant class/field in java code. -
- Navigation Functionality - - - - - - - - -
- This is done via the standard hyperlink navigation functionali= ty in Eclipse; per default - it is done by pressing F3 while the cursor is on a class/field or = by pressing - Ctrl - and the mouse button to perform the same navigation. - For java completion and navigation to work the file needs to r= eside inside an Eclipse - Java project, otherwise no completion will occur. - - Note: - Java completion does not require a Hibernate console configu= ration to be used. - -
-
- Table/Column completion - Table and column completion is also available for all table an= d column attributes. -
- Table and Column Completion - - - - - - - - -
- - Important: - Table/Column completion requires a proper configured hiberna= te console configuration - and this configuration should be the default for the project whe= re the - hbm.xml - resides. - - You can check which console configuration is selected under th= e Properties of a project - and look under the - Hibernate Settings - page. When a proper configuration is selected it will = be used to fetch the - table/column names in the background. - - Note: - Currently it is not recommended to use this feature on large= databases since it does - not fetch the information iteratively. It will be improved in fu= ture versions. - -
-
- Configuration property completion - In - cfg.xml - code completion for the value of <property>= ; name attributes - is available. -
- Property Completion - - - - - - - - -
-
-
-
- Structured Hibernate Mapping and Configuration File Editor</tit= le> - <para>The structured editor represents the file in the tree form. It a= lso allows to modify the - structure of the file and its elements with the help of tables provi= ded on the right-hand - area.</para> - <para>To open any mapping file in the editor, choose <emphasis> - <property>Open With > Hibernate 3.0 XML Editor</property> - </emphasis> option from the context menu of the file. The editor sho= uld look as - follows:</para> - <figure> - <title>Structured hbm.xml Editor - - - - - - - For the configuration file you should choose - Open With > Hibernate Configuration 3.0 XML Editor - option. -
- Structured cfg.xml Editor - - - - - -
-
-
- JBoss Tools Properties Editor - The editor is meant for editing .properties f= iles. It contains two - tabs: the Properties (UI) tab and the Source tab for - manual editing. - For hibernate.properties file JBoss= Tools Properties - Editor provides content assist which is available both = for hibernate properties - and property values. You can make use of the content assist while ed= iting the file in the - Source view and in the Properties view of the editor. - To add the property in the Properties view,= click the - Add - button. -
- Adding the Property - - - - - -
- In the - Name - field press - Ctrl+Space - to invoke the content assist. It will suggest - 'hibernate.' - which is the prefix for all hibernate properties. After = selecting - 'hibernate.' - and invoking the content assist again, other prefixes an= d properties are displayed - as the proposals with a description of each one. -
- Content Assist for Properties Names - - - - - -
- When invoking the content assist in the - Value - field, it also provides a list of proposals. -
- Content Assist for Properties Values - - - - - -
- In the Source view of the editor, content a= ssist also could be - invoked both for properties names and values: -
- Content Assist in the Source view - - - - - -
-
- Content Assist in the Source view - - - - - -
-
-
- Reveng.xml Editor - A - reveng.xml - file is used to customize and control how reverse engine= ering is performed by the - tools. The plugins provide an editor to ease the editing of this fil= e and hence used to - configure the reverse engineering process. - The editor is intended to allow easy definition of type mappings= , table include/excludes - and specific override settings for columns, e.g. define an explicit = name for a column when the - default naming rules are not applicable. - - Note: - Not all the features of the - .reveng.xml - file are exposed or fully implemented in the editor, b= ut the main functionality - is there. To understand the full flexibility of the - reveng.xml - , please see - - - The editor is activated as soon as an - .reveng.xml - file is opened. To get an initial - reveng.xml - file the Reverse Engineering File Wizard can be started via - - Ctrl+N - and - Hibernate > Hibernate Reverse Engineering File (reveng.x= ml) - then. -
- ChooseReverse Engineering File Wizard - - - - - - - - -
- Or you can get it via the Code Generation Launcher by checking the - proper section in the - Main - tab of the . - The following screenshot shows the - Overview - page where the wanted console configuration is selected = (auto-detected if - Hibernate 3 support is enabled for the project) -
- Overview Page - - - - - - - - -
- The - Table Filter - page allows you to specify which tables to include and e= xclude. Pressing - - Refresh - shows the tables from the database that have not yet bee= n excluded. -
- Table Filters Page - - - - - - - - -
- The - Type Mappings - page is used for specifying type mappings from JBDC type= s to any Hibernate type - (including usertypes) if the default rules are not applicable. Here = again to see the database - tables press - Refresh - button underneath. More about type mappings you can find= further in the section. -
- Type Mappings Page - - - - - - - - -
- The - Table and Columns - page allows you to explicit set e.g. which hibernatetype= and propertyname that - should be used in the reverse engineered model. For more details on = how to configure the - tables while reverse engineering read the section. -
- Table and Columns Page - - - - - - - - -
- Now that you have configured all necessary parts, you can learn = how to work with Hibernate Console Perspective. -
-
- Hibernate Console Perspective - The Hibernate Console Perspective combines = a set of views which allow - you to see the structure of your mapped entities/classes, edit HQL q= ueries, execute the - queries, and see the results. To use this perspective you need to cr= eate a . -
- Viewing the entity structure - To view your new configuration and entity/class structure, swi= tch to Hibernate - Configurations View. Expanding the tree allows you to= browse the class/entity - structure and see the relationships. -
- Hibernate Console Perspective - - - - - - - - -
- The Console Configuration does not dynami= cally adjust to changes - done in mappings and java code. To reload the configuration select= the configuration and - click the - Reload - button in the view toolbar or in the context menu. - Besides, it's possible to open source and mapping files f= or objects showed in - Hibernate Configurations View. Just bring u= p the context menu for a - necessary object and select - Open Source File - to see appropriate Java class or - Open Mapping File - to open a proper - .hbm.xml. -
- Opening Source for Objects - - - - - -
-
- Mapping Diagram - In order to get a visual feel on how entities are related as= well as view their - structures, a Mapping Diagram is provided. = It is available by right - clicking on the entity you want a mapping diagram for and then c= hoosing - Mapping Diagram. -
- Mapping Diagram - - - - - - - - -
- To make Mapping Diagram usage easier yo= u can use Rules, Grid,Snap to= Geometry - checkboxes in the - View - menu. -
- View menu - - - - - -
- If you will select - Rules - checkbox, the view print page scale will be added to= the page. The numbers on - the scale show its size in inches.If you click on the scale a - Ruler Guide - will appear on the diagram. You can connect any diag= ram item to it.To connect - the items you should move their tops to the Ruler Guide. And whi= le moving the ruler guide, - the items will be moved together with it as a whole. -
- Moving the Ruler guide - - - - - -
- If you'll select - Grid - checkbox, the grid will appear on the diagram. -
- Grid on Mapping diagram - - - - - -
- The checkbox - Snap to Geometry - helps to put the items of the diagram into allineati= on with the grid. - For better navigating through the diagram use Outl= ine view which - is available in the structural and graphical modes. -
- Navigating in the Structural Mode - - - - - -
- To switch over between the modes use the buttons in the top-= right corner of the - Outline view. -
- Navigating in the Graphical Mode - - - - - -
- The options in the context menu of the mapping diagram are l= isted in the next - table. - - Context Menu Options of the Mapping Diagram - - - - - - - - Icon - - - Command - - - Description - - - - - - - - - - - - - - - - Show|Hide connections - - Allows to select what types of connections should b= e shown on the diagram: - - Property Mappings - - - Class Mappings - - - Associations - - - Foreign key constraints - - - - - - - - - Select All - - - Makes all the diagram elements selected - - - - - - - - - - - - - - Auto layout - - - Used to dispose all the items of the diagram in a = standard manner - - - - - - - - - - - - - - Export as Image - - - Allows to export a diagram as = .png - , - - .jpeg - or - .bmp - - - - - -
- When you open the context menu while clicking an item on the= diagram, it quite differs - from the one described before. -
- Context Menu in Mapping Item - - - - - -
- The next table describes all the extra options in the menu o= f mapping items: - - Extra Options in the Context Menu of Mapping Item - - - - - - - - Icon - - - Command - - - Description - - - - - - - - - - - - - - - - Open Source File - - - Makes it possible to open a source file for a chos= en object/element. The - selected element will be highlighted in the open file.= - - - - - - - - - - - - - - Open Mapping File - - - Makes it possible to open a mapping file for a cho= sen object/element. The - selected element will be highlighted in the open file.= - - - - - - - - - - - - - - Show|Hide shape(s) - - - Used to hide/show an item on the mapping diagram - - - - - - - - - - - - - - Expand|Collapse shape(s) - - - Used for expanding/collapsing fields of the item - - - - -
- - Tip: - All the described types of the context menu are also avail= able in the Outline view. - - The below table lists the actions that could be performed us= ing the keyboard keys (or - keys combinations). - - Hibernate Mapping Diagram Shortcut Keys - - - - - - - Command - - - Binding - - - - - - - Scroll the diagram content - - - Ctrl + Shift + arrows - - - - - Collapse/Expand selected item(s) - - - Enter - - - - - Show/Hide selected item(s) - - - + - - - - - Sort items in alphabetical order or return the ini= tial state - - - Space - - - - - Navigate between the items - - - Arrows - - - - -
- It's possible to save the diagram in the eclipse worksp= ace. Click the usual - - File > Save As - option, the wizard will ask you to set the location = within you project where - to save the file and give the name for the diagram. The item&apo= s;s names concatenated - with the ampersand symbols are set as the default name for a dia= gram. The file is saved - with the .hibernate extension. -
- The Diagram saved in the Workspace - - - - - -
- - Note: - If you restart the Eclipse with the mapping diagram opened= , the mapping diagram will - be restored with the message like on the figure below. To view= the diagram content, you - should perform the refreshing. - -
- The Diagram after Restarting the Eclipse - - - - - -
-
- The Diagram after Refreshing - - - - - -
- There are some useful commands in the toolbar. -
- The Diagram View Toolbar - - - - - -
- They are described in the table below. - - Command in Diagram View Toolbar - - - - - - - - Icon - - - Command - - - Description - - - - - - - - - - - - - - - - Refresh Visual Mapping - - - It update Mapping Diagram if = Console - Configuration was changed. - - - - - - - - - - - - - - Zoom Box - - - Used to define scale of the diagram. Also it's use= d for Mapping - Diagram printing. If you want to put the = whole diagram to one print page, you need sele= ct Page option in the Zoom Box. - - - - - - - - - - - - - - Auto layout - - - Used to arrange all diagram items in a standard ma= nner. - - - - - - - - - - - - - - Show|Hide connections - - - Used to show or hide connection on the diagram. Mo= reover you can choose what - type of connections must be present on the diagram (Property - Mappings, Class Mappings, Associations or Foreign key co= nstraints) - . - - - - - - - - - - - - - - Expand|Collapse - - - Used for expanding/collapsing fields of the item.<= /para> - - - - - - - - - - - - - - Show|Hide shape(s) - - - Used to hide/show an item on the mapping diagram.<= /para> - - - - -
-
-
-
- Prototyping Queries - Queries can be prototyped by entering them into the = HQL or - Criteria Editor. To execute a query you sho= uld click the green run - button in the editor toolbar or press - Ctrl+Enter - . -
- HQL Editor and Hibernate Criteria Editor - To open the query editors right-click your project Console - Configuration and select HQL Editor (or Hibernate Criteria Editor). -
- Opening HQL Editor - - - - - -
- - Tip: - If the context menu items are disabled then you need at fi= rst to create a Session Factory. That is done by simply expandin= g the Session - Factory node. - - When open the editors they should automatically detect the c= hosen Console - Configuration. - To get a prefill query for any entity (or any entity child n= ode) listed in the - - Session Factory - you should double-click it. This will open the HQL Editor - with the associated query. - Choosing - HQL Editor - in the context menu for any entity (or any entity ch= ild node) will also open - the HQL editor with the associated query. If you choose - Hibernate Criteria Editor - in the context menu, it will open Hibernat= e Criteria - Editor with the associated criteria. -
- Generating Simple Queries - - - - - - - - -
- It's also possible to copy a portion of code from - .java - file into the HQL or = Criteria - editor. To do this make use of the Quick Fix option (= - Ctrl + 1). -
- Quick Fix Option Demonstration - - - - - -
- You can also update the original java code according to chan= ges in the HQL or Criteria - editor. For that you should save your HQL/Criteria query and sub= mit the replacing in - appeared confirmation dialog. -
- Updating Java Code - - - - - -
- Also you can pin HQL editor and Criteria - editor for one tab in Hibernate Query Res= ult view. For - that you need click on Stick result to one tab - button( - - - - ). In the issue query executions results wi= ll be shown in one tab (no - more will be opened). - Moreover you are able to rename tab in Hibernate = Query Result. - Click the tab, and type a new name in Property View->T= ab name field. -
- Tab Renaming - - - - - -
-
-
- Error Handling - Errors during creation of the Session Factory or running the - queries (e.g. if your configuration or query is incorrect) will = be shown in a message - dialog or inclined in the view that detected the error, you may = get more information about - the error in the Error Log View on the righ= t pane. - Results of a query will be shown in the Hibernate = Query Result - View and details of possible errors (syntax errors,= database errors, etc.) - can be seen in the Error Log View. - - Note: - HQL queries are executed by default using list()<= /literal> thus without any - limit of the size of the output the query could return a large= result set. You might run - out of memory. To avoid this you can put a value in the Max re= sults field to reduce the - number of elements returned. - -
-
- Dynamic Query Translator - If the Hibernate Dynamic Query Translator View is visible while - writing in the HQL Editor it will show the = generated SQL for a HQL - query. -
- Hibernate Dynamic Query Translator View - - - - - - - - -
- The translation is done each time you stop typing into the e= ditor, if there are errors - in the HQL the parse exception will be shown embedded in the vie= w. -
-
-
- Properties View - As you can see on the figure,when clicking on class/entity Properties - view shows the number of query results as well as the= time of executing. -
- Properties View - - - - - - - - -
- It also displays the structure of any persistent object select= ed in the Hibernate Query Results View. Editing is not yet sup= ported. -
- Properties View for Selected Object - - - - - - - - -
- You can also use Properties view when cli= cking on the configuration - itself in Hibernate Configuration View( ). -
-
-
- Hibernate:add JPA annotations refactoring - Using this wizard you can add the next Hibernate annotations to = the class: - @Column - , - @Entity - , - @ManyToOne - , - @OneToMany - , - @OneToOne - , - @ManyToMany - , - @MappedSuperclass - , - @Id - , - @GeneratedValue - , - @Version - - - - - - @Column - is added to all String properties. - - - - @Entity - is always declared before any class where it doesn't= present. - - - - @ManyToOne - , - @OneToMany - , - @OneToOne - , - @ManyToMany - - this annotations are declared according to the cla= sses hierarchy. - - - - @MappedSuperclass - is added to abstract superclasses. - - - - @Id - , - @GeneratedValue - are added automatically only to the properties under= the name "Id",where they - don't present. - - - - @Version - is declared in case you select . - - - - Note: - This section doesn't cover the meaning of the Hibern= ate annotations - , for more information read Hibernate - Annotations Documentation . - - To open this wizard you should right click the class you want to= enrich with annotations - - >Source>Generate Hibernate/JPA annotations - . You will see the Hibernate:add JPA annotations dialog. = -
- Starting Hibernate:add JPA annotations dialog - - - - - -
- In the top of it you can see the list of all classes that will = be passed through - refactoring. Besides the class you have selected in this list you ca= n also find its - superclasses and the classes that objects present in the current cla= ss as properties. If you - want to add new classes or package to the list of classes, you shoul= d click the Back button. In result you will see Add clas= ses and - packages page. -
- Add classes and packages page - - - - - -
- Here you can add one more classes or whole package, moreover you= can limit dependencies - depth by selecting depth control option (more a= bout this option you will - find in ). When finished - just press the Next button and you will be retu= rned to The - following classes will be changed page and will be able= to continue work with - it. - By default the tags are added to the fields of selected classes.= But you can change this - option to - Getters - in - Preferred location of Annotations - dropdownlist and then all the annotations will be added = to the getter methods. If - you choose - Auto select from class preference - then the annotations are added according to the majority= of the already existed - ones positions. - If it's nessecary to map your String properties to the columns = that length differ from - the default value(255) ,change - Default string length field - and @Column(length =3D your length) will be= created before every String - property. - You can add optimistic locking capability to a= n entity bean by selecting - - Enable optimistic locking - checkbox. This operation will add version property to al= l the selected classes. - The property will be also annotated with @Version ,getter and setter= will be created. If the - property is already exists,it won't be created ,but the getters,sett= ers will be generated. If - there is already @MappedSuperclass with version in the base class of= the current class - - - "version" - is not inserted into the current class. - After defining all necessary settings in the current step press = - Next - and follow the next wizard steps. -
- Hibernate:add JPA annotations view - - - - - -
- The view represents two windows: one with the source code and an= d the second with - refactored one. With the help of - - - - , - - - - , - - - - , - - - - buttons you can quickly navigate between the di= fferences in the code. If - you don't agree with some changes you can't undo them but you can re= move the class from the - list of classes that need refactoring. -
- List of classes that need refactoring - - - - - -
- To apply the changes click - Finish - . -
-
- Enable debug logging in the plugins - It is possible to configure the eclipse plugin to route all logg= ing made by the plugins - and hibernate code it self to the Error Log View in Eclipse. - Error Log View is very useful tool to solve= any problem which appears in Hibernate Tools Plugins. = - You can use if there are troubles with setting up Hibernat= e Console Configuration. = - This is done by editing the - hibernate-log4j.properties - in - org.hibernate.eclipse/ directory/jar - . This file includes a default configuration that only lo= gs WARN and above to a set - of custom appenders (PluginFileAppender and PluginLogAppender). You = can change these settings - to be as verbose or silent as you please - see Hibernate Documentation for interesting categories and Lo= g4j documentation. -
- Relevant Resources Links - Find more on how to configure logging via a log4j property fil= e in Log4j documentation. -
-
-
- Hibernate support for Dali plugins in Eclipse WTP - Starting from 3.0.0 Alpha1 version of JBoss Tools Hibernate plugins - support Eclipse Dali integration what now makes it possible to use a= Hibernate as a complete - JPA development platform. - When starting a new JPA project from - New > Other > JPA > JPA Project - (or simply - New > JPA Project - in JPA Perspective), the first wiza= rd page looks as - follows. -
- Starting JPA Project - - - - - -
- It's possible here to select a target runtime and change th= e project configuration, - or you can leave everything as it is. - On the JPA Facet page you should choose Hibernate as a target pl= atform. Also select the - proper database connection, if it is defined, or add a new one by cl= icking the - Add connection - link. - Hitting - Finish - will generate the project. -
- Targeting at Hibernate Platform - - - - - -
- - Note: - Please note, if you choose Hibernate as a platform while creat= ing a JPA/Dali project, a - Hibernate Console Configuration for the project is created automat= ically when the wizard - finishes its work. It allows a full usage of Hibernate T= ools features - without additional setup. - - By enabling Hibernate platform specific features you can now gen= erate DDL and Entities. - For that find - JPA Tools > Generate Tables from Entities/Generate Entit= ies from Tables - options in the context menu of your JPA project. -
- Generate DDL/Entities - - - - - -
- - Note: - Please, remember to put the proper database driver to the clas= spath of your - project. - - The Generate Entities wizard first will ask= you to choose the - directory where all output will be written. -
- Generate Entities Wizard - - - - - -
- To generate entities you can use: - - - a Hibernate Console Configuration (proposed by default) - Just make sure that the - Use Console Configuration - checkbox is selected and choose a needed configurati= on from the - Console configurations - list box. -
- Generate Entities Wizard - - - - - -
-
-
- - - or a DTP connection directly - Just uncheck - Use Console Configuration - and adjust database settings. - - - All the same you do with Generate Entities Wizard you can do wit= h Generate DDL wizard. - Special feature for Generate DDL wizard is possible automatic execut= ion of Generation DDL in - the database. -
- Generate DDL Wizard - - - - - -
- Thus, you can now have the Hibernate runtime support in Eclipse = JPA projects. -
-
Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 0.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 0_a.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 0_b.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 1.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 2.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 2_a.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 3.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 4_a.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 4_b.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 4_c.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 4_d.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 5.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 6.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 7.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/images/plugins/plugins_= 8.png =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (Binary files differ) Modified: trunk/hibernatetools/docs/reference/en-US/introduction.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/hibernatetools/docs/reference/en-US/introduction.xml 2011-03-02 2= 2:58:02 UTC (rev 29454) +++ trunk/hibernatetools/docs/reference/en-US/introduction.xml 2011-03-02 2= 3:34:47 UTC (rev 29455) @@ -151,15 +151,15 @@
Other relevant resources on the topic = - Hibernate Tools page on hibernate.org. + The Hibernate Tools page on hibernate.org= . - All JBoss Tools release documentation can be= found at http://docs.jboss.org= /tools in the corresponding release directory. + All JBDS release documentation can be found = on the RedHat Documentation website. - There is some extra information about Hibernate on the JBoss Wiki page. + There is some additional information on Hibernate on the JBoss Wiki page. = - The latest JBoss Tools documentation builds = are available at http://download.jboss.org/jbosstools/nightly-docs. + Nighly documentation builds are available here.
= Deleted: trunk/hibernatetools/docs/reference/en-US/master.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/hibernatetools/docs/reference/en-US/master.xml 2011-03-02 22:58:0= 2 UTC (rev 29454) +++ trunk/hibernatetools/docs/reference/en-US/master.xml 2011-03-02 23:34:4= 7 UTC (rev 29455) @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - = - -]> - - - Hibernate Tools Reference Guide - - - - - = - - - = - = - - MaxAndersenma= x.andersen(a)jboss.com - OlgaChikvina - SvetlanaMukhinasmukhina(a)exadel.com = - - - 2007 - 2008 - 2009 - 2010 - JBoss by Red Hat - - - - Version: 3.3.1.GA - - - - - - - - - - - - <para> - <ulink url=3D"http://download.jboss.org/jbosstools/nightly-docs= /en/hibernatetools/pdf/Hibernatetools_Reference_Guide.pdf">PDF version</uli= nk> - </para> -</abstract> - - </bookinfo> - <toc/> - = - &introduction; - &setup; = - &codegenarchitecture; - &plugins; = - &ant; - &reveng; - &codegen; = - = - = - </book> Deleted: trunk/hibernatetools/docs/reference/en-US/master_output.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/hibernatetools/docs/reference/en-US/master_output.xml 2011-03-02 = 22:58:02 UTC (rev 29454) +++ trunk/hibernatetools/docs/reference/en-US/master_output.xml 2011-03-02 = 23:34:47 UTC (rev 29455) @@ -1,5822 +0,0 @@ -<?xml version=3D"1.0" encoding=3D"UTF-8"?> -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" -"http://www.docbook.org/xml/4.3/docbookx.dtd" - -[ -<!ENTITY introduction SYSTEM "introduction.xml"> -<!ENTITY setup SYSTEM "setup.xml"> -<!ENTITY codegenarchitecture SYSTEM "codegenarchitecture.xml"> -<!ENTITY plugins SYSTEM "plugins.xml"> -<!ENTITY ant SYSTEM "ant.xml"> -<!ENTITY reveng SYSTEM "reverseengineering.xml"> -<!ENTITY codegen SYSTEM "codegen.xml"> - -<!ENTITY seamlink "../../seam/html_single/index.html"> -<!ENTITY aslink "../../as/html_single/index.html"> -<!ENTITY esblink "../../esb_ref_guide/html_single/index.html"> -<!ENTITY gsglink "../../GettingStartedGuide/html_single/index.html"> -<!ENTITY hibernatelink "../../hibernatetools/html_single/index.html"> -<!ENTITY jbpmlink "../../jbpm/html_single/index.html"> -<!ENTITY jsflink "../../jsf/html_single/index.html"> -<!ENTITY jsfreflink "../../jsf_tools_ref_guide/html_single/index.html"> -<!ENTITY jsftutoriallink "../../jsf_tools_tutorial/html_single/index.html"> -<!ENTITY strutsreflink "../../struts_tools_ref_guide/html_single/index.htm= l"> -<!ENTITY strutstutoriallink "../../struts_tools_tutorial/html_single/index= .html"> = - -]><book xmlns:diffmk=3D"http://diffmk.sf.net/ns/diff"> - <bookinfo> - <title>Hibernate Tools Reference Guide - - - - - = - - - = - = - - MaxAndersenma= x.andersen(a)jboss.com - OlgaChikvina - SvetlanaMukhinasmukhina(a)exadel.com = - - - 2007 - 2008 - 2009 - 2010 - JBoss by Red Hat - - - - Version: 3.3.1.GA - - - - - - = - - - - - - - PDF version - - - - - - = - = - - - Introduction - - Hibernate Tools is a tool= set for Hibernate 3 = and related projects. The tools provide Ant - tasks and Eclipse plugins for performing reverse engineering, code= generation, visualization - and interaction with Hibernate. - -
- Key Features - - First, we propose to look through the list of key features t= hat you can benefit from - if you start using Hibernate Tools= . - - - Key Functionality for Hibernate Tools - - = - - - - = - - - Feature - Benefit - Chapter - - - - - - - - Code Generation through Ant Task - - - Allows to execute mapping or Java code g= eneration from reverse - engineering, schema generation and generat= ion of other artifacts - during the build process. - = - ant task - - - - - Wizards for creation - purposes and code - generation - - - A set of wizards are provided with the = Hibernate Eclipse tools to - quickly create common Hibernate files such= as configuration - (cfg.xml) files, mapping files and revenge= .xml as well. Code - Generation wizard helps to generate a seri= es of various artifacts, - there is even support for completely rever= se engineer an existing - database schema. - = - hibernat= e mapping file - h= ibernate configuration file - code gen= eration = - - - - - - - - Mapping and Configuration files - Editors - - - - Support auto-completion and syntax highl= ighting. Editors also - support semantic auto-completion for class= names and property/field - names, making it much more versatile than = a normal XML - editor. - - mappin= g and configuration files editors - - - - - Tools for organizing and controlling Rev= erse Engineering - - - Code Generation wizard provides powerful= functionality for - generating a series of various artifacts l= ike domain model classes, - mapping files, annotated EJB3 entity beans= , etc. and reveng.xml file - editor allows to control this processes. - - code generation<= /link> = - reveng.xml ed= itor - - - - - Hibernate Console - - - It is a new perspective in Eclipse which= provides an overview of - your Hibernate Console configurations, wer= e you also can get an - interactive view of your persistent classe= s and their relationships. - The console allows you to execute HQL quer= ies against your database - and browse the result directly in Eclipse.= - - hibernate con= sole - - = - - - HQL Editor and Hibernate Criteria Editor - - - The editors are intended for writing, editing and= executing HQL queries and criterias. They also support the functionality f= or generating = - simple queries. - - hql an= d hibernate criteria editors - - - - - Functional Mapping Diagram - - - Makes possible to visualize structure of= entities and - relationships between them. - = - mapping diagr= am - - - - - - Eclipse JDT integration - - - Hibernate Tools integrates into the Java= code completion and build - support of Java in Eclipse. This gives you= code completion of HQL - inside Java code. Additionally, Hibernate = Tools will add problem - markers if your queries are not valid agai= nst the console - configuration associated with the project.= - - - - - -
-
- = -
- Other relevant resources on the topic - = - - All JBoss Developer Studio/JBoss Tools release documentation= you can find athttp://docs.jbo= ss.org/tools in the corresponding release directory. - There is some extra information about Hidernate on JBoss Wiki page. = - The latest documentation builds are available at http://download.jbo= ss.org/jbosstools/nightly-docs. -
- -
- - = - - Download and install Hibernate Tools - Hibernate Tools can be used= "standalone" via Ant 1.6.x or - fully integrated into an Eclipse + WTP based IDE, such as JBDS/JBoss Tools, - or a default Eclipse + WTP installation. The following sections descri= be the install steps in - these environments. - - Note: - The Hibernate Tools 3.3.0= (the current release version) requires - Eclipse Galileo 3.5. - -
- JBoss Tools - JBoss Tools 3.1.0 (the la= test release) includes Hibernate - Tools 3.3.0 and thus nothing is required besides downloading - and installing JBoss Tools. I= f you need to update to a newer version of - the Hibernate Tools just foll= ow the instructions in the Eclipse IDE - section. -
-
- Eclipse IDE - To install the Hibernate Tools into any Eclipse - 3.5 based IDE you can either use JBoss Tools Update Site - or install it manually. - If you want to install the Hibernate= Tools distribution manually you - need to: - - - Download from www.eclipse.org: - - - birt-report-framework-2_5_0.zip - - - birt-wtp-integration-sdk-2_3_2.zip - - - dtp-sdk_1.7.0.zip - - - eclipse-SDK-3.5-win32.zip - - - emf-runtime-2.5.0.zip - - - GEF-SDK-3.5.0.zip - - - org.eclipse.swtbot.eclipse.test-2.0.0.371-dev-e35.zip - - - org.eclipse.swtbot.eclipse-2.0.0.340-dev.zip - - - site-1.6.2.zip - - - tptp.sdk-TPTP-4.6.0.zip - - - wtp-sdk-R-3.1-20090616035105.zip - - - xsd-runtime-2.5.0.zip - - - - - Then you should unpack these files into Eclipse install fold= er. - - - From hiberna= te.org-Download Overview download Hibernate Tools - . - = - - - Unpack Hibernate Tools in eclipse/dropins folder - - - - Note: - If you need more detailed instructions on plugins installatio= n and general usage of eclipse - then check out https://eclipse-tutorial.dev.java.net/ and especially https://eclipse-tutorial.dev.java.net/visual-tutorials/updatemanager.ht= ml which - covers using the update manager. - -
- Usage of Eclipse WTP - The Hibernate Tools plu= gins currently use WTP - 3.x which at this time is the latest stable release f= rom the Eclipse Webtools - project. - Because the WTP project not always have had proper versioning = of their plugins there - might exist WTP plugins in your existing eclipse directory from ot= her Eclipse based projects - that are from an earlier WTP release but has either the same versi= on number or higher. It is - thus recommended that if you have issues with WTP provided feature= s to try and install the - plugins on a clean install of eclipse to ensure there are no versi= on collisions. -
-
-
- Ant - To use the tools via Ant you need the - hibernate-tools.jar - and associated libraries. The libraries are included in = the distribution from the - Hibernate website and the Eclipse updatesite. The libraries are loca= ted in the eclipse plugins - directory at - /plugins/org.hibernate.eclipse.x.x.x/l= ib/tools/ - . These libraries are 100% independent from the eclipse p= latform. How to use these - via ant tasks are described in the Ant Tools chapter. -
-
- = - = - - Code generation architecture - - The code generation mechanism in the H= ibernate Tools consists of a few - core concepts. This section explains their overall structure which are= the same for the Ant and - Eclipse tools. - -
- Hibernate Meta Model - - The meta model is the model used by Hibernate Core to perform it= s object relational - mapping. The model includes information about tables, columns, class= es, properties, - components, values, collections etc. The API is in org.hibernate.mapping - and its main entry point is the Configur= ation class, the same class that is - used to build a session factory. - - The model represented by the Configu= ration class can be build in many - ways. The following list the currently supported ones in Hibernate Tools. - - - - - A Core configuration uses Hibernate Core and supports read= ing - hbm.xml - files, requires a - hibernate.cfg.xml - . Named core in Eclipse and = - <configuration> - in ant. - - - - An Annotation configuration uses Hibernate Annotations and= supports - hbm.xml - and annotated classes, requires a - hibernate.cfg.xml - . Named annotations in Eclipse and = - <annotationconfiguration> - in ant. - - - - A JPA configuration uses a Hibernate EntityManager and sup= ports - hbm.xml - and annotated classes requires that the project ha= s a - META-INF/persistence.xml - in its classpath. Named JPA in Eclipse and = - <jpaconfiguration> - in ant. - - - - A JDBC configuration uses Hibe= rnate Tools reverse engineering - and reads its mappings via JDBC metadata + additional reverse = engineering files - (reveng.xml). Automatically used in Eclipse when doing reverse= engineering from JDBC and - named = - <jdbcconfiguration> - in ant. - - - - - In most projects you will normally use only one of the Core, Ann= otation or JPA - configuration and possibly the JDBC configuration if you are using t= he reverse engineering - facilities of Hibernate Tools= . - - - Note: - No matter which Hibernate Configuration type you are using Hibernate - Tools supports them. - - - The following drawing illustrates the core concepts: - - -
- Hibernate Core Concepts - - - - - - - - - - -
-
- - The code generation is done based on the Configuration model no = matter which type of - configuration have been used to create the meta model, and thus the = code generation is - independent on the source of the meta model and represented via Expo= rters. -
- -
- Exporters - - Code generation is done in so called Exporters. An Exporte= r is handed a - Hibernate Meta Model represented as a Configuration ins= tance and it is then - the job of the exporter to generate a set of code artifacts. - - The tools provides a default set of Exporter's which can be used= in both Ant and the - Eclipse UI. Documentation for these Exporters is in the Ant Tools - and Eclipse Plugins chapters. - - Users can provide their own customer Exporter's, either by custo= m classes implementing the - Exporter interface or simply be providing custom templates. This is = documented at -
-
- - = - - Eclipse Plugins - This chapter will introduce you to the functionality that Hibernate - Tools provide within Eclipse. That is a set of wizards an= d editors for simplifying - the work with Hibernate. -
- Introduction - Hibernate Eclipse Tools include wizards for creating Hibernate m= apping files, - configuration files (.cfg.xml), revenge.xml as well as wizards for a= djusting Console - Configuration and Code Generation. Special structured and XML editor= s, editors for executing - HQL and Criteria queries are also provided in Hibernate Console. Ref= er to Key Features section = to find all benefits that you - can take advantage of while using the tools within Eclipse. - - Note: - Please note that these tools do not try to hide any functional= ity of Hibernate. The tools make wor= king with Hibernate easier, - but you are still encouraged/required to read the Hibernate Documentation to fully uti= lize - Hibernate Tools and espec= ially Hibernate it - self. - -
- Download base project - You can download exa= mple projects which are used for this chapter. - JPA base project is available on documentation resources page - together with base Java projec= t. - Also you need start database. - - Note: - How to run database you can know in Getting Started Guide. - -
-
-
- Creating a Hibernate Mapping File - Hibernate mapping files are used to specify how your objects are= related to database - tables. - To create basic mappings for properties and associations, i. e. = generate - .hbm.xml - files, Hibernate Tools provide a basic wizard which you = can bring up by navigating - - New > Hibernate XML mapping file. - At first you'll be asked to select a package or multiple individ= ual classes to map. - It's also possible to create an empty file, don't select any package= s or classes and an - empty .hbm will be created in the specified location - With depth cont= rol option you can def= ine - dependences depth for choosing classes (it means to set level of ref= erences which is used to - collect linked classes to the selection). -
- Hibernate XML Mapping File Wizard - - - - - -
- The next wizard page lists the mappings to be generated. As you = see Customers, Orders, Productlines and - Products c= lasses added under depth control - driving. -
- Mappings to be generated - - - - - -
- This wizard page outputs a generated .hbm files preview. -
- Preview Generated Mapping Files - - - - - -
- Pressing Finish creates t= he files. -
-
- Creating a Hibernate Configuration File - To be able to reverse engineer, prototype queries, and of course= to simply use Hibernate Core a - hibernate.properties - or - hibernate.cfg.xml - file is needed. The Hibernat= e Tools provide a wizard for - generating the - hibernate.cfg.xml - file if you do not already have such one. - Start the wizard by clicking - New > Other (Ctrl+N) - , then - Hibernate > Hibernate Configuration= File (cfg.xml) - and press - Next - or on a web Seam project in the Web Projects view - WebContent -> New -> File ->= Hibernate Configuration 3.0 - . After selecting the wanted location for the - hibernate.cfg.xml - file, you will see the following page: -
- Hibernate Configuration File Wizard - - - - - - - - -
- - Note: - The contents in the combo boxes for the JDBC driver class and = JDBC URL change - automatically, depending on the Dialect and actual driver you have= chosen. - - Enter your configuration information in this dialog. Details abo= ut the configuration - options can be found in Hibernate - Reference Documentation. - Press - Finish - to create the configuration file, after optionally creat= ing a Console - configuration, the - hibernate.cfg.xml - will be automatically opened in an editor. The last opti= on - Create Console Configuration - is enabled by default and when enabled, it will automati= cally use the - hibernate.cfg.xml - for the basis of a Console configuration. -
-
- Hibernate Console Configuration - A Console configuration describes how the Hibernate plugin should - configure Hibernate and what = configuration files, including which - classpath are needed to load the POJO's, JDBC drivers etc. It is req= uired to make usage of - query prototyping, reverse engineering and code generation. You can = have multiple named - console configurations. Normally you would just need one per project= , but more is definitely - possible if your project requires this. -
- Creating a Hibernate Console Configuration - You can create a console configuration by running the Console Configuration - Wizard, shown in the following screenshot. The same w= izard will also be used if - you are coming from the - hibernate.cfg.xml - wizard and had enabled - Create Console Configuration - . - - Note: - The wizard will look at the current selection in the IDE and= try and auto-detect the - settings which you then can just approve or modify to suit your = needs. - - - The dialog consists of five tabs: - - - - Main - for the basic/required settings - - -
- Creating Hibernate Console Configuration - - - - - - - - -
- The following table describes the available settings on the - Main - tab. The wiz= ard can automatically detect the default values for most of them if - you started the wizard with the relevant java project or resource = selected. - - Hibernate Console Configuration Parameters - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Name - - - The unique name of the console configuration - - - Name of the selected project - - - - - Type - - - Choose between "Core", "Annotations" and "JPA". - Note that the two latter requires running Eclipse IDE wi= th a JDK 5 runtime, - otherwise you will get classloading and/or version error= s. - - - No default value - - - - - Project - - - The name of a java project which classpath should be= used in the console - configuration - - - Name of the selected project - - - - - Database connection - - - DTP provided connection that you can use instead of = what is in cfg.xml and jpa - persistence.xml. It's possible to use either already con= figured hibernate or - JPA connection or specify a new one here. - - - [Hibernate Configured connection] - - - - - Property file - - - Path to a hibernate.properties file - - - First hibernate.properties file found in the selecte= d project - - - - - Configuration file - - - Path to a hibernate.cfg.xml file - - - First hibernate.cfg.xml file found in the selected p= roject - - - - - Persistence unit - - - Name of the persistence unit to use - - - No default= value (let Hibernate Entity Manager find the persistence unit or it - can be defined manually using Browse button) - - - - -
- - Tip: - The two latter set= tings are usually not required if you specify a project and it has - - - /hibernate.cfg.xml - - or - - /META-INF/persistence.xml - - in its project classpath. - - - - - - Options - for the additional/optional settings - - -
- Options Tab of the Console Configuration Wizard - - - - - -
- The next table describes Hibernate Console Configuration optio= ns available on the - - Options - tab. - - Hibernate Console Configuration Options - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Database dialect - - - Define a d= atabase dialect. It's possible either to write your value or - choose from list. - - - No default value - - - - - Naming strategy - - - Fully qualified classname of a custom NamingStrategy= . Only required if you use - a special naming strategy. - - - No default value - - - - - Entity resolver - - - Fully qualified classname of a custom EntityResolver= . Only required if you - have special xml entity includes in your mapping files.<= /para> - - - No default value - - - - -
- - - - Classpath - for classpath - - -
- Specifying Classpath in Hibernate Console Configuration</ti= tle> - <mediaobject> - <imageobject role=3D"fo"> - <imagedata align=3D"center" fileref=3D"images/plugins/plugins_= 3.png" format=3D"PNG"></imagedata> - </imageobject> - <imageobject role=3D"html"> - <imagedata align=3D"center" fileref=3D"images/plugins/plugins_= 3.png" format=3D"PNG"></imagedata> - </imageobject> - </mediaobject> - </figure> - <para>The following table specifies the parameters of the Classpath = tab of the wizard.</para> - <table> - <title>Hibernate Console Configuration Classpath - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Classpath - - - The classpath for loading POJO and JDBC drivers; onl= y needed if the default - classpath of the Project does not contain the required c= lasses. Do not add - Hibernate core libraries or dependencies, they are alrea= dy included. If you get - ClassNotFound errors then check this list for possible m= issing or redundant - directories/jars. - - - Empty - - - - - Include default classpath from project - - - When enabled the project classpath will be appended = to the classpath specified - above - - - Enabled - - - - - - - - - Mappings - for additional mappings - - -
- Specifying additional Mappings in Hibernate Console Configu= ration - - - - - - - - -
- Parameters of the Mappings tab of the Hibernate Console Configuration - wizard are explained below: - - Hibernate Console Configuration Mappings - - - - - - - - Parameter - - - Description - - - Auto detected value - - - - - - - Mapping files - - - List of additional mapping files that should be load= ed. Note: A - hibernate.cfg.xml or persistence.xml can also contain ma= ppings. Thus if these are - duplications here, you will get "Duplicate mapping" erro= rs when using the console - configuration. - - - empty - - - - -
- - - and the last tab - Common - - - -
- Common Tab of the Console Configuration Wizard - - - - - -
- It allows to define general aspects of the launch configuratio= n including storage - location, console encoding and some others. - Clicking - Finish - creates the configuration and shows it in the Hibernate Configurations - view. -
- Console Overview - - - - - - - - -
-
-
- Modifying a Hibernate Console Configuration - When you created a hibernate console configuration you can mod= ify it in 2 ways: - - - right-click on the configuration in - Hibernate Configurations View-&g= t;Edit Configuration - or just double-click on Console Configuration - item. -
- Opening Edit Configuration Wizard - - - - - -
- After clicking you will see the Edit Configuration Wizard= that is similar to - - Create Console Configuration - ,described in = Creating a Hibernate Console - Configuration section. -
- - use Properties view for modifying some of Console Configur= ation properties. -
- Properties View - - - - - -
- The following table describes the available settings in th= e Properties view. Most - properties are changeable by left click but some are not. - Properties - - - - - - - - Property - - - Description - - - Is Changeable - - - - - - - Additional mapping files - - - List of additional mapping files that should b= e loaded. - - - False - - - - - Configuration file - - - Path to a hibernate.cfg.xml file - - - False - - - - - Connection - - - DTP provided connection that you can use inste= ad of what is in cfg.xml - and jpa persistence.xml. It's possible to use eith= er already configured - hibernate or JPA connection or specify a new one h= ere. - - - True - - - - - Name - - - The unique name of the console configuration - - - True - - - - - Project - - - The name of a java project which classpath sho= uld be used in the console - configuration - - - True - - - - - Properties file - - - Path to a hibernate.properties file - - - False - - - - - Type - - - Choo= se between "CORE", "ANNOTATIONS" and - "JPA" according to the method of relational mappin= g you want to - use. Note, the two latter requires running Eclipse= IDE with a JDK 5 runtime, - otherwise you will get classloading and/or version= errors. - - - True - - - - - -
-
-
-
- Closing Hibernate Console Configuration - To close Hibernate Console Configu= ration you need do rig= ht-click - your configuration and choose Close Configuration option -
- Close Hibernate Console Configuration - - - - - -
- While closing configuration the connection with database will = be closed, jar libs will - be unlock (for Windows) and other resources will set as free. -
-
-
- Reverse Engineering and Code Generation - A "click-and-generate" reverse engineering and code generation f= acility is - available. This facility allows you to generate a range of artifacts= based on database or an - already existing Hibernate configuration, be that mapping files or a= nnotated classes. Some of - these are POJO Java source file, Hibernate - .hbm.xml - , - hibernate.cfg.xml - generation and schema documentation. - To start working with this process, start the Hibernate Code - Generation which is available in the toolbar via the Hibernate icon or via the - Run > Hibernate Code Generation - menu item. -
- Code Generation Launcher - When you click on - Open Hibernate Code Generation Dialo= g... - the standard Eclipse launcher dialog will appear. In t= his dialog you can create, - edit and delete named Hibernate code generation "launchers". -
- Getting Hibernate Code Generation Wizard - - - - - - - - -
- -
- Hibernate Code Generation Wizard - - - - - - - - -
- The first time you create a code generation launcher you shoul= d give it a meaningful - name, otherwise the default prefix - New_Generation - will be used. - - Tip: - The "At least one exporter option must be selected" is just = a warning - stating that for this launch to work you need to select an expor= ter on the Exporter tab. - When an exporter has been selected the warning will disappear. - - The dialog also have the standard tabs - Refresh - and - Common - that can be used to configure which directories should= be automatically - refreshed and various general settings launchers, such as saving t= hem in a project for - sharing the launcher within a team. - On the - Main - tab you see the following fields: - - Code generation "Main" tab fields - - - - - - - - Field - - - Description - - - - - - - Console Configuration - - - The name of the console configuration which should b= e used when code - generating - - - - - Output directory - - - Path to a directory where all output will be written= by default. It's possible - to enter absolute directory path, for example - "d:/temp= ". Be aware that existing - files will be overwritten, so be sure to specify the cor= rect directory. - - - - - Reverse engineer from JDBC Connection - - - If enabled, the tools will reverse engineer the data= base available via the - connection information in the selected Hibernate Console= Configuration and - generate code based on the database schema. If not enabl= ed, the code generation - will just be based on the mappings already specified in = the Hibernate Console - configuration. - - - - - Package - - - The package name here is used as the default package= name for any entities - found when reverse engineering - - - - - reveng.xml - - - Path to a reveng.xml file. A reveng.xml file allows = you to control certain - aspects of the reverse engineering. e.g. how jdbc types = are mapped to hibernate - types and especially important which tables are included= /excluded from the - process. Clicking "setup" allows you to select an existi= ng reveng.xml file or - create a new one. See more details about the reveng.xml = file in . - - - - - reveng. strategy - - - If reveng.xml does not provide enough customization = you can provide your own - implementation of an ReverseEngineeringStrategy. The cla= ss needs to be in the - classpath of the Console Configuration, otherwise you wi= ll get class not found - exceptions. See for details and an - example of a custom strategy. - - - - - Generate basic typed composite ids - - - A table that has a multi-column primary key a <co= mposite-id> mapping - will always be created. If this option is enabled and th= ere are matching - foreign-keys each key column is still considered a 'basi= c' scalar (string, long, - etc.) instead of a reference to an entity. If you disabl= e this option a - <key-many-to-one> instead. Note: a - <many-to-one> property is still cre= ated, but is simply marked - as non-updatable and non-insertable. - - - - - Detect optimistic lock columns - - - Automatically detect optimistic lock columns. Contro= llable via reveng. - strategy; the current default is to use columns named VE= RSION or TIMESTAMP. - - - - - Detect many-to-many tables - - - Automatically detect many-to-many tables. Controllab= le via reveng. - strategy. - - - - - Detect one-to-one associations - - - Reverse engineering detects one-to-one associations= via primary key and both - hbm.xml and annotation generation generates the proper c= ode for it. - The detection is enabled by default (except for Sea= m 1.2 and Seam 2.0) - reverse engineering. For Hibernate Tools generation ther= e is a checkbox to disable - if not wanted. - - - - - Use custom templates - - - If enabled, the Template directory will be searched = first when looking up the - templates, allowing you to redefine how the individual t= emplates process the - hibernate mapping model. - - - - - Template directory - - - A path to a directory with custom templates - - - - -
-
-
- Exporters - The - Exporters - tab is used to specify which type of code that should = be generated. Each - selection represents an Exporter that is responsible for generatin= g the code, hence the - name. -
- Selecting Exporters - - - - - - - - -
- The following table describes in short the various exporters. = Remember you can - add/remove any Exporters depending on your needs. - - Code generation "Exporter" tab fields - - - - - - - Field - - - Description - - - - - - - Domain code - - - Generates POJO's for all the persistent classes and = components found in the - given Hibernate configuration. - - - - - DAO code - - - Generates a set of DAO's for each entity found. - - - - - Hibernate XML Mappings - - - Generate mapping (hbm.xml) files for each entity. - - - - - Hibernate XML Configuration - - - Generate a hibernate.cfg.xml file. Used to keep the = hibernate.cfg.xml update - with any new found mapping files. - - - - - Schema Documentation (.html) - - - Generates a set of html pages that documents the dat= abase schema and some of - the mappings. - - - - - Generic Exporter (hbmtemplate) - - - Fully customizable exporter which can be used to per= form custom - generation. - - - - - Schema Export (.ddl) - - - Generates the appropriate SQL DDL and allows you to = store the result in a file - or export it directly to the database. - - - - -
- Each Exporter listens to certain properties and these can be s= etup in the - Properties - section where you can add/remove predefined or custome= r properties for each of - the exporters. The following table lists the time of writing prede= fined properties: - - - Exporter Properties - - - - - - - Name - - - Description - - - - - - - jdk5 - - - Generate Java 5 syntax - - - - - ejb3 - - - Generate EJB 3 annotations - - - - - for_each - - - Specifies for which type of model elements the exp= orter should create a file - and run through the templates. Possible values are: en= tity, component, - configuration - - - - - template_path - - - Custom template directory for this specific export= er. You can use Eclipse - variables. - - - - - template_name - - - Name for template relative to the template path - - - - - outputdir - - - Custom output directory for this specific exporter= . You can use Eclipse - variables. - - - - - file_pattern - - - Pattern to use for the generated files, relatively= for the output dir. - Example: {package-name}/{class-name}.java . - - - - - dot.executable - - - Executable to run GraphViz (only relevant, but opt= ional for Schema - documentation) - - - - - drop - - - Output will contain drop statements for the tables= , indices and - constraints - - - - - delimiter - - - If specified the statements will be dumped to this= file - - - - - create - - - Output will contain create statements for the tabl= es, indices and - constraints - - - - - scriptToConsole - - - The script will be output to Console - - - - - exportToDatabase - - - Executes the generated statements against the data= base - - - - - outputFileName - - - If specified the statements will be dumped to this= file - - - - - haltOnError - - - Halts the build process if an error occurs - - - - - format - - - Applies basic formatting to the statements - - - - - schemaUpdate - - - Updates a schema - - - - -
-
- To add a property to the chosen Exporter click the - Add - button in the Properties section. In the appeared dialog - you should select the property from the proposed list and the valu= e for it. -
- Adding the Property for Schema Export (.ddl) - - - - - -
- - Tip: - If the property is a directory, it is possible to browse dir= ectories in the Value - field. - -
- Specifying the Property Value - - - - - -
-
-
-
- Hibernate Mapping and Configuration File Editor - The Hibernate Mapping File editor provides XML editing functionality - for the - hbm.xml - and - cfg.xml - files. The editor is based on the Eclipse WTP tools and = extends its functionality - to provide Hibernate specific code completion. -
- XML Editing Functionality - - - - - - - - -
-
- Java property/class completion - Package, class, and field completion is enabled for relevant X= ML attributes. The - auto-completion detects its context and limits the completion for = e.g. - <property> and only shows the properties/fiel= ds available in the - enclosing <class> , <subclass> etc. It is also - possible to navigate from the - hbm.xml - files to the relevant class/field in java code. -
- Navigation Functionality - - - - - - - - -
- This is done via the standard hyperlink navigation functionali= ty in Eclipse; per default - it is done by pressing F3 while the cursor is on a class/field or = by pressing - Ctrl - and the mouse button to perform the same navigation. - For java completion and navigation to work the file needs to r= eside inside an Eclipse - Java project, otherwise no completion will occur. - - Note: - Java completion does not require a Hibernate console configu= ration to be used. - -
-
- Table/Column completion - Table and column completion is also available for all table an= d column attributes. -
- Table and Column Completion - - - - - - - - -
- - Important: - Table/Column completion requires a proper configured hiberna= te console configuration - and this configuration should be the default for the project whe= re the - hbm.xml - resides. - - You can check which console configuration is selected under th= e Properties of a project - and look under the - Hibernate Settings - page. When a proper configuration is selected it will = be used to fetch the - table/column names in the background. - - Note: - Currently it is not recommended to use this feature on large= databases since it does - not fetch the information iteratively. It will be improved in fu= ture versions. - -
-
- Configuration property completion - In - cfg.xml - code completion for the value of <property>= ; name attributes - is available. -
- Property Completion - - - - - - - - -
-
-
-
- Structured Hibernate Mapping and Configuration File Editor</tit= le> - <para>The structured editor represents the file in the tree form. It a= lso allows to modify the - structure of the file and its elements with the help of tables provi= ded on the right-hand - area.</para> - <para>To open any mapping file in the editor, choose <emphasis> - <property moreinfo=3D"none">Open With > Hibernate 3.0 XML Edito= r</property> - </emphasis> option from the context menu of the file. The editor sho= uld look as - follows:</para> - <figure float=3D"0"> - <title>Structured hbm.xml Editor - - - - - - - For the configuration file you should choose - Open With > Hibernate Configuration= 3.0 XML Editor - option. -
- Structured cfg.xml Editor - - - - - -
-
-
- JBoss Tools Properties Editor - The editor is meant for editing .prop= erties files. It contains two - tabs: the Properties (UI) tab= and the Source tab for - manual editing. - For hibernate.properties fi= le JBoss Tools Properties - Editor provides content assist which is available both = for hibernate properties - and property values. You can make use of the content assist while ed= iting the file in the - Source view and in the Properties view of the editor. - To add the property in the Propertie= s view, click the - Add - button. -
- Adding the Property - - - - - -
- In the - Name - field press - Ctrl+Space - to invoke the content assist. It will suggest - 'hibernate.' - which is the prefix for all hibernate properties. After = selecting - 'hibernate.' - and invoking the content assist again, other prefixes an= d properties are displayed - as the proposals with a description of each one. -
- Content Assist for Properties Names - - - - - -
- When invoking the content assist in the - Value - field, it also provides a list of proposals. -
- Content Assist for Properties Values - - - - - -
- In the Source view of the= editor, content assist also could be - invoked both for properties names and values: -
- Content Assist in the Source view - - - - - -
-
- Content Assist in the Source view - - - - - -
-
-
- Reveng.xml Editor - A - reveng.xml - file is used to customize and control how reverse engine= ering is performed by the - tools. The plugins provide an editor to ease the editing of this fil= e and hence used to - configure the reverse engineering process. - The editor is intended to allow easy definition of type mappings= , table include/excludes - and specific override settings for columns, e.g. define an explicit = name for a column when the - default naming rules are not applicable. - - Note: - Not all the features of the - .reveng.xml - file are exposed or fully implemented in the editor, b= ut the main functionality - is there. To understand the full flexibility of the - reveng.xml - , please see <= /xref> - - - The editor is activated as soon as an - .reveng.xml - file is opened. To get an initial - reveng.xml - file the Reverse Engineering= File Wizard can be started via - - Ctrl+N - and - Hibernate > Hibernate Reverse Engin= eering File (reveng.xml) - then. -
- ChooseReverse Engineering File Wizard - - - - - - - - -
- Or you can get it via the Code Gener= ation Launcher by checking the - proper section in the - Main - tab of the Hibernate Code= Generation - Wizard. - The following screenshot shows the - Overview - page where the wanted console configuration is selected = (auto-detected if - Hibernate 3 support is enabled for the project) -
- Overview Page - - - - - - - - -
- The - Table Filter - page allows you to specify which tables to include and e= xclude. Pressing - - Refresh - shows the tables from the database that have not yet bee= n excluded. -
- Table Filters Page - - - - - - - - -
- The - Type Mappings - page is used for specifying type mappings from JBDC type= s to any Hibernate type - (including usertypes) if the default rules are not applicable. Here = again to see the database - tables press - Refresh - button underneath. More about type mappings you can find= further in the Type Mappings section. -
- Type Mappings Page - - - - - - - - -
- The - Table and Columns - page allows you to explicit set e.g. which hibernatetype= and propertyname that - should be used in the reverse engineered model. For more details on = how to configure the - tables while reverse engineering read the Specific table - configuration section. -
- Table and Columns Page - - - - - - - - -
- Now that you have configured all necessary parts, you can learn = how to work with Hibernate Console Perspective<= /property>. -
-
- Hibernate Console Perspective - The Hibernate Console Perspective combines a set of views which allow - you to see the structure of your mapped entities/classes, edit HQL q= ueries, execute the - queries, and see the results. To use this perspective you need to cr= eate a Console configuration. -
- Viewing the entity structure - To view your new configuration and entity/class structure, swi= tch to Hibernate - Configurations View. Expanding the tree allows you to= browse the class/entity - structure and see the relationships. -
- Hibernate Console Perspective - - - - - - - - -
- The Console Configuration does not dynamically adjust to changes - done in mappings and java code. To reload the configuration select= the configuration and - click the - Reload - button in the view toolbar or in the context menu. - Besides, it's possible to open source and mapping files for ob= jects showed in - Hibernate Configurations View. Just bring up the context menu for a - necessary object and select - Open Source File - to see appropriate Java class or - Open Mapping File - to open a proper - .hbm.xml. -
- Opening Source for Objects - - - - - -
-
- Mapping Diagram - In order to get a visual feel on how entities are related as= well as view their - structures, a Mapping Diagram is provided. It is available by right - clicking on the entity you want a mapping diagram for and then c= hoosing - Mapping Diagram. -
- Mapping Diagram - - - - - - - - -
- To make Mapping Diagram usage easier you can use Rules, <= property moreinfo=3D"none">Grid,Snap= to Geometry - checkboxes in the - View - menu. -
- View menu - - - - - -
- If you will select - Rules - checkbox, the view print page scale will be added to= the page. The numbers on - the scale show its size in inches.If you click on the scale a - Ruler Guide - will appear on the diagram. You can connect any diag= ram item to it.To connect - the items you should move their tops to the Ruler Guide. And whi= le moving the ruler guide, - the items will be moved together with it as a whole. -
- Moving the Ruler guide - - - - - -
- If you'll select - Grid - checkbox, the grid will appear on the diagram. -
- Grid on Mapping diagram - - - - - -
- The checkbox - Snap to Geometry - helps to put the items of the diagram into allineati= on with the grid. - For better navigating through the diagram use Outline view which - is available in the structural and graphical modes. -
- Navigating in the Structural Mode - - - - - -
- To switch over between the modes use the buttons in the top-= right corner of the - Outline view. -
- Navigating in the Graphical Mode - - - - - -
- The options in the context menu of the mapping diagram are l= isted in the next - table. - - Context Menu Options of the Mapping Diagram - - - - - - - - Icon - - - Command - - - Description - - - - - - - - - - - - - - - - Show|Hide connections - - Allows to select what types of connections should b= e shown on the diagram: - - Property Mappings - - - Class Mappings - - - Associations - - - Foreign key constraints - - - - - - - - - Select All - - - Makes all the diagram elements selected - - - - - - - - - - - - - - Auto layout - - - Used to dispose all the items of the diagram in a = standard manner - - - - - - - - - - - - - - Export as Image - - - Allows to export a diagram as .png - , - - .jpeg - or - .bmp - - - - - -
- When you open the context menu while clicking an item on the= diagram, it quite differs - from the one described before. -
- Context Menu in Mapping Item - - - - - -
- The next table describes all the extra options in the menu o= f mapping items: - - Extra Options in the Context Menu of Mapping Item - - - - - - - - Icon - - - Command - - - Description - - - - - - - - - - - - - - - - Open Source File - - - Makes it possible to open a source file for a chos= en object/element. The - selected element will be highlighted in the open file.= - - - - - - - - - - - - - - Open Mapping File - - - Makes it possible to open a mapping file for a cho= sen object/element. The - selected element will be highlighted in the open file.= - - - - - - - - - - - - - - Show|Hide shape(s) - - - Used to hide/show an item on the mapping diagram - - - - - - - - - - - - - - Expand|Collapse shape(s) - - - Used for expanding/collapsing fields of the item - - - - -
- - Tip: - All the described types of the context menu are also avail= able in the Outline view. - - The below table lists the actions that could be performed us= ing the keyboard keys (or - keys combinations). - - Hibernate Mapping Diagram Shortcut Keys - - - - - - - Command - - - Binding - - - - - - - Scroll the diagram content - - - Ctrl + Shift + arrows - - - - - Collapse/Expand selected item(s) - - - Enter - - - - - Show/Hide selected item(s) - - - + - - - - - Sort items in alphabetical order or return the ini= tial state - - - Space - - - - - Navigate between the items - - - Arrows - - - - -
- It's possible to save the diagram in the eclipse workspace. = Click the usual - - File > Save As - option, the wizard will ask you to set the location = within you project where - to save the file and give the name for the diagram. The item's n= ames concatenated - with the ampersand symbols are set as the default name for a dia= gram. The file is saved - with the .hibernate extensi= on. -
- The Diagram saved in the Workspace - - - - - -
- - Note: - If you restart the Eclipse with the mapping diagram opened= , the mapping diagram will - be restored with the message like on the figure below. To view= the diagram content, you - should perform the refreshing. - -
- The Diagram after Restarting the Eclipse - - - - - -
-
- The Diagram after Refreshing - - - - - -
- There are some useful commands in the toolbar. -
- The Diagram View Toolbar - - - - - -
- They are described in the table below. - - Command in Diagram View Toolbar - - - - - - - - Icon - - - Command - - - Description - - - - - - - - - - - - - - - - Refresh Visual Mapping - - - It update Mapping Diag= ram if Console - Configuration was changed. - - - - - - - - - - - - - - Zoom Box - - - Used to define scale of the diagram. Also it's use= d for Mapping - Diagram printing. If you want to put the = whole diagram to one print page, you= need select Page option in the Zoom Box. - - - - - - - - - - - - - - Auto layout - - - Used to arrange all diagram items in a standard ma= nner. - - - - - - - - - - - - - - Show|Hide connections - - - Used to show or hide connection on the diagram. Mo= reover you can choose what - type of connections must be present on the diagram (Property - Mappings, Cla= ss Mappings, Associations= or Foreign key constraints) - . - - - - - - - - - - - - - - Expand|Collapse - - - Used for expanding/collapsing fields of the item.<= /para> - - - - - - - - - - - - - - Show|Hide shape(s) - - - Used to hide/show an item on the mapping diagram.<= /para> - - - - -
-
-
-
- Prototyping Queries - Queries can be prototyped by entering them into the HQL or - Criteria Editor. To execu= te a query you should click the green run - button in the editor toolbar or press - Ctrl+Enter - . -
- HQL Editor and Hibernate Criteria Editor - To open the query editors right-click your project Console - Configuration and select HQL Editor (or Hibernate Criteria = Editor). -
- Opening HQL Editor - - - - - -
- - Tip: - If the context menu items are disabled then you need at fi= rst to create a Session Factory. Tha= t is done by simply expanding the Session - Factory node. - - When open the editors they should automatically detect the c= hosen Console - Configuration. - To get a prefill query for any entity (or any entity child n= ode) listed in the - - Session Factory - you should double-click it. This will open the HQL Editor - with the associated query. - Choosing - HQL Editor - in the context menu for any entity (or any entity ch= ild node) will also open - the HQL editor with the associated query. If you choose - Hibernate Criteria Editor - in the context menu, it will open Hibernate Criteria - Editor with the associated criteria. -
- Generating Simple Queries - - - - - - - - -
- It's also possible to copy a portion of code from - .java - file into the HQL or Criteria - editor. To do this make use of the Quick Fix option (= - Ctrl + 1). -
- Quick Fix Option Demonstration - - - - - -
- You can also update the original java code according to chan= ges in the HQL or Criteria - editor. For that you should save your HQL/Criteria query and sub= mit the replacing in - appeared confirmation dialog. -
- Updating Java Code - - - - - -
- Also you can pin HQL editor and Criteria - editor for one tab in H= ibernate Query Result view. For - that you need click on Stick result = to one tab - button( - - - - ). In the issue query executions results wi= ll be shown in one tab (no - more will be opened). - Moreover you are able to rename tab in Hibernate Query Result. - Click the tab, and type a new name in Property View->Tab name field. -
- Tab Renaming - - - - - -
-
-
- Error Handling - Errors during creation of the Se= ssion Factory or running the - queries (e.g. if your configuration or query is incorrect) will = be shown in a message - dialog or inclined in the view that detected the error, you may = get more information about - the error in the Error Log View on the right pane. - Results of a query will be shown in the Hibernate Query Result - View and details of possible errors (syntax errors,= database errors, etc.) - can be seen in the Error Log View. - - Note: - HQL queries are executed by default using list() thus without any - limit of the size of the output the query could return a large= result set. You might run - out of memory. To avoid this you can put a value in the Max re= sults field to reduce the - number of elements returned. - -
-
- Dynamic Query Translator - If the Hibernate Dynamic Query T= ranslator View is visible while - writing in the HQL Editor= it will show the generated SQL for a HQL - query. -
- Hibernate Dynamic Query Translator View - - - - - - - - -
- The translation is done each time you stop typing into the e= ditor, if there are errors - in the HQL the parse exception will be shown embedded in the vie= w. -
-
-
- Properties View - As you can see on the figure,when clicking on class/entity Properties - view shows the number of query results as well as the= time of executing. -
- Properties View - - - - - - - - -
- It also displays the structure of any persistent object select= ed in the Hibernate Query Results View. Editing is not yet supported. -
- Properties View for Selected Object - - - - - - - - -
- You can also use Properties view when clicking on the configuration - itself in Hibernate Configuration View( Modifying a - Hibernate Console Configuration section). -
-
-
- Hibernate:add JPA annotations refactoring - Using this wizard you can add the next Hibernate annotations to = the class: - @Column - , - @Entity - , - @ManyToOne - , - @OneToMany - , - @OneToOne - , - @ManyToMany - , - @MappedSuperclass - , - @Id - , - @GeneratedValue - , - @Version - - - - - - @Column - is added to all String properties. - - - - @Entity - is always declared before any class where it doesn't= present. - - - - @ManyToOne - , - @OneToMany - , - @OneToOne - , - @ManyToMany - - this annotations are declared according to the cla= sses hierarchy. - - - - @MappedSuperclass - is added to abstract superclasses. - - - - @Id - , - @GeneratedValue - are added automatically only to the properties under= the name "Id",where they - don't present. - - - - @Version - is declared in case you select Enable optimistic - locking. - - - - Note: - This section doesn't cover the meaning of the Hibernate annotations - , for more information read Hibernate - Annotations Documentation . - - To open this wizard you should right click the class you want to= enrich with annotations - - >Source>Generate Hibernate/JPA a= nnotations - . You will see the Hibernate:add JPA annotations dialog. = -
- Starting Hibernate:add JPA annotations dialog - - - - - -
- In the top of it you can see the list of all classes that will = be passed through - refactoring. Besides the class you have selected in this list you ca= n also find its - superclasses and the classes that objects present in the current cla= ss as properties. If you - want to add new classes or package to the list of classes, you shoul= d click the Back button. In result y= ou will see Add classes and - packages page. -
- Add classes and packages page - - - - - -
- Here you can add one more classes or whole package, moreover you= can limit dependencies - depth by selecting depth control option (more about this option you will - find in Creating a Hibernate Mapping= File). When finished - just press the Next button an= d you will be returned to The - following classes will be changed page and will be able= to continue work with - it. - By default the tags are added to the fields of selected classes.= But you can change this - option to - Getters - in - Preferred location of Annotations - dropdownlist and then all the annotations will be added = to the getter methods. If - you choose - Auto select from class preference - then the annotations are added according to the majority= of the already existed - ones positions. - If it's nessecary to map your String properties to the columns = that length differ from - the default value(255) ,change - Default string length field - and @Column(length =3D your length) will be= created before every String - property. - You can add optimistic locking capability to a= n entity bean by selecting - - Enable optimistic locking - checkbox. This operation will add version property to al= l the selected classes. - The property will be also annotated with @Version ,getter and setter= will be created. If the - property is already exists,it won't be created ,but the getters,sett= ers will be generated. If - there is already @MappedSuperclass with version in the base class of= the current class - - - "version" - is not inserted into the current class. - After defining all necessary settings in the current step press = - Next - and follow the next wizard steps. -
- Hibernate:add JPA annotations view - - - - - -
- The view represents two windows: one with the source code and an= d the second with - refactored one. With the help of - - - - , - - - - , - - - - , - - - - buttons you can quickly navigate between the di= fferences in the code. If - you don't agree with some changes you can't undo them but you can re= move the class from the - list of classes that need refactoring. -
- List of classes that need refactoring - - - - - -
- To apply the changes click - Finish - . -
-
- Enable debug logging in the plugins - It is possible to configure the eclipse plugin to route all logg= ing made by the plugins - and hibernate code it self to the Error = Log View in Eclipse. - Error Log View is very useful tool to solve any problem wh= ich appears - in Hibernate Tools Plugins. You can use if there are troubles with s= etting up Hibernate Console Co= nfiguration. - This is done by editing the - hibernate-log4j.properties - in - org.hibernate.eclipse/ directory/jar - . This file includes a default configuration that only lo= gs WARN and above to a set - of custom appenders (PluginFileAppender and PluginLogAppender). You = can change these settings - to be as verbose or silent as you please - see Hibernate Documentation for interesting c= ategories and Log4j documentation. -
- Relevant Resources Links - Find more on how to configure logging via a log4j property fil= e in Log4j documentation. -
-
-
- Hibernate support for Dali plugins in Eclipse WTP - Starting from 3.0.0 Alpha1 version of JBoss Tools Hibernate plugins - support Eclipse Dali integration what now makes it possible to use a= Hibernate as a complete - JPA development platform. -
- Creating JPA project with Hibernate support - When starting a new JPA project from - New > Other > JPA > JPA Pro= ject - (or simply - New > JPA Project - in JPA Perspective), the first wizard page looks= as - follows. -
- Starting JPA Project - - - - - -
- It's possible here t= o select a target runtime and change the project configuration, - or you can leave everything as it is. - On the JPA Facet pag= e you should choose Hibernate as a target platform. Also select the - proper database connection, if it is defined, or add a new one by = clicking the - Add connection - link. - Hitting - Finish - will generate the project. -
- Targeting at Hibernate Platform - - - - - -
- - Note: - Please note, if yo= u choose Hibernate as a platform while creating a JPA/Dali project, - a Hibernate Console Configuration for the project is created aut= omatically when the wizard - finishes its work. It allows a full usage of Hibernate Tools features - without additional setup. - -
-
- Generating DDL and Entities - By enabling Hibernat= e platform specific features you can now generate DDL and Entities. - For that find - JPA Tools > Generate Tables from Entities/Generate Entities from - Tables - options in the context menu of your JPA project. -
- Generate DDL/Entities - - - - - -
- - Note: - Please, remember t= o put the proper database driver to the classpath of your - project. - - The Generate Entities wizard first will ask you to choos= e the - directory where all output will be written. -
- Generate Entities Wizard - - - - - -
- To generate entities you can use: - - - a Hibernate Console Configuration (proposed by default) - Just make sure that the - Use Console Configuration - checkbox is selected and choose a needed configura= tion from the - Console configurations - list box. -
- Generate Entities Wizard - - - - - -
-
-
- - - or a DTP connection directly - Just uncheck - Use Console Configuration - and adjust database settings. - - - All the same you do = with Generate Entities Wizard you can do with Generate DDL wizard. - Special feature for Generate DDL wizard is possible automatic exec= ution of Generation DDL in - the database. -
- Generate DDL Wizard - - - - - -
- Thus, you can now have the Hibernate runtime support in Eclips= e JPA projects. -
-
- Hibernate Annotations Support - Also Hibernate Annotations are supported in Dali Java Persistence - Tools. The next annotations are integrated with JPA - Details view: - - - Id Generator annotations - @Ge= nericGenerator and @GeneratedValue -
- @GenericGenerator support in Dali - - - - - -
-
- @GeneratedValue support in Dali - - - - - -
-
- - Property annotations- @Discrim= inatorFormula, @Generated Annotation= , @Index annotation -
- @Index support in Dali - - - - - -
-
- - Mapping Queries annotations - = @NamedQuery and @NamedNativeQuery -
- Add New Named Query Dialog with Hibernate Support</titl= e> - <mediaobject> - <imageobject> - <imagedata fileref=3D"images/plugins/dali_integration10.pn= g"></imagedata> - </imageobject> - </mediaobject> - </figure> - <figure float=3D"0"> - <title>@NamedQuery support in Dali - - - - - -
-
- - Association annotations in an embed= dable o= bject (@OneToOne, @ManyToOne, @OneToMany or @ManyToMany) -
- <diffmk:wrapper diffmk:change= =3D"added">Hibernate Support for Embeddable Object</diffmk:wrapper> - - - - - -
-
-
- More information about Hibernate Annotation you can find in Hibernate - Annotations Reference Guide. -
-
- Relevant Resources Links - There is full information about native Dali plugin features on= Eclipse Documentation - page. -
-
-
- = - = - - Ant Tools - - Maybe somebody will find it more preferable to use Ant for generat= ion purposes. Thus, this - chapter is intended to get you ready to start using Hibernate Tools vi= a Ant tasks. - -
- Introduction - - The - hibernate-tools.jar - contains the core for the Hi= bernate Tools. It is used as the - basis for both the Ant tasks described in this document and the ecli= pse plugins both available - from tools.hibernate.org. The - hibernate-tools.jar - is located in your eclipse plugins directory at - /plugins/org.hibernate.eclipse.x.x.x/l= ib/tools/hibernate-tools.jar. - This jar is 100% independent from the eclipse platform and can t= hus be used independently - of eclipse. - - - Note: - There might be incompatibilities with respect to the Hibernate= 3.jar bundled with the - tools and your own jar. Thus to avoid any confusion it is recommen= ded to use the - hibernate3.jar and hibernate-annotations.jar bundled with the tool= s when you want to use the - Ant tasks. Do not worry about using e.g. Hibernate 3.2 jar's with = e.g. a Hibernate 3.1 - project since the output generated will work with previous Hiberna= te 3 versions. - -
- -
- The <hibernatetool> Ant Task - - To use the ant tasks you need to have the - hibernatetool - task defined. That is done in your - build.xml - by inserting the following xml (assuming the jars are in= the - lib directory): - - - - - - - - = - -]]> - - This = - <taskdef> - defines an Ant task called - hibernatetool - which now can be used anywhere in your ant - build.xml - files. It is important to include all the Hibernate Tools - dependencies as well as the jdbc driver. - - Notice that to use the annotation based Configuration you must <= ulink url=3D"http://annotations.hibernate.org">get a release. - - - - When using the - hibernatetool - task you have to specify one or more of the following: - - - - - - (|| - |) - (,,,...) = -]]> - - - Hibernatetool attributes - - - - - - - - - - - - - Attribute name - - Definition - - Attribute use - - - - - - - destdir - - - - Destination directory for files generated with exporte= rs - - - - Required - - - - - - templatepath - - - - A path to be used to look up user-edited templates - - - - Optional - - - - - - classpath - - - - A classpath to be used to resolve resources, such as m= appings and - usertypes - - - - Optional, but very often required - - - - - - - property (and propertyset) - - - - Used to set properties to control the exporters. Mostl= y relevant for providing - custom properties to user defined templates - - - - Optional - - - - - - configuration (annotationconfiguration, jpaconfigurati= on, - jdbcconfiguration) - - - - One of four different ways of configuring the Hibernat= e Meta Model must be - specified - - - - - - - - - - hbm2java (hbm2cfgxml, hbmtemplate, etc.) - - - - One or more of the exporters must be specified - - - - - - - - - - -
- -
- Basic examples - - The following example shows the most basic setup for generatin= g pojo's via <hbm2java> from a normal - - hibernate.cfg.xml - . The output will be put in the - ${build.dir}/generated - directory. - - - - - - = - - -]]> - - - The following example is similar, but now we are performing mu= ltiple exports from the - same configuration. We are exporting the schema via <hbm2= dll>, generates some DAO code via <hbm2dao> - and finally runs a custom code generation via <hbmtemplat= e>. This is again from a normal - hibernate.cfg.xml - and the output is still put in the - - ${build.dir}/generated - - directory. Furthermore the example also shows where a = classpath is specified - when you e.g. have custom usertypes or some mappings that is neede= d to be looked up as a - classpath resource. - - - - - - - - - - -]]> - -
-
- -
- Hibernate Configurations - - Hibernatetool supports four different Hiber= nate configurations: A - standard Hibernate configuration = - (<configuration>), Annotation based - configuration (<annotationconfiguration>), - JPA persistence based configuration = - (<jpaconfiguration>) and a JDBC based - configuration (<jdbcconfiguration>) - for use when reverse engineering. - - Each have in common that they are able to build up a Hibernate C= onfiguration object from - which a set of exporters can be run to generate various output. - - - Note: - Output can be anything, e.g. specific files, statements execut= ion against a database, - error reporting or anything else that can be done in java code. - - - The following sections describe what the various configurations = can do, plus lists the - individual settings they have. - -
- Standard Hibernate Configuration (<configuration>)</tit= le> - - <para>A = - <code><configuration></code> - is used to define a standard Hibernate configuration. A standard = Hibernate - configuration reads the mappings from a <emphasis> - <property moreinfo=3D"none">cfg.xml</property> - </emphasis> and/or a fileset.</para> - - <programlisting format=3D"linespecific" role=3D"XML"><![CDATA[<confi= guration - configurationfile=3D"hibernate.cfg.xml" - propertyfile=3D"hibernate.properties" - entityresolver=3D"EntityResolver classname" - namingstrategy=3D"NamingStrategy classname" -> - <fileset...> - = - </configuration>]]></programlisting> - - <table frame=3D"topbot"> - <title>Configuration attributes - - - - - - - - - - - - - Attribute name - - Definition - - Attribute use - - - - - - - configurationfile - - - - The name of a Hibernate configuration file, e.g. "hi= bernate.cfg.xml" - - - - Optional - - - - - - propertyfile - - - - The name of a property file, e.g. "hibernate.propert= ies" - - - - Optional - - - - - - entity-resolver - - - - Name of a class that implements org.xml.sax.EntityRe= solver. Used if the - mapping files require custom entity resolver - - - - Optional - - - - - - - namingstrategy - - - - Name of a class that implements org.hibernate.cfg.Na= mingStrategy. Used for - setting up the naming strategy in Hibernate which contro= ls the automatic naming of - tables and columns.In JPA projects naming strategy is su= pported for default Name/Columns mapping - - - - Optional - - - - - - fileset - - - - A standard Ant fileset. Used to include hibernate ma= pping files. Remember that - if mappings are already specified in the hibernate.cfg.x= ml then it should not be - included via the fileset as it will result in duplicate = import exceptions. - - - - - - - - - - - - -
- Example - - This example shows an example where no - - hibernate.cfg.xml - - exists, and a - hibernate.properties - and fileset is used instead. - - - Note: - Hibernate will still read any global - hibernate.properties - available in the classpath, but the specified prop= erties file here will - override those values for any non-global property. - - - - - - - - - - - - -]]> - -
-
- -
- Annotation based Configuration (<annotationconfiguration&g= t;) - - An = - <annotationconfiguration> - is used when you want to read the metamodel from EJB3/Hibernate An= notations - based POJO's. - - - Important: - To use it remember to put the jar files needed for using hib= ernate annotations in the - classpath of the = - <taskdef>, i. e. - hibernate-annotations.jar and hibernate-commons-annotations.jar.= - - - The = - <annotationconfiguration> - supports the same attributes as a = - <configuration> - except that the configurationfile attribute is now required as tha= t is from - where an AnnotationConfiguration gets the lis= t of classes/packages it - should load. - - Thus the minimal usage is: - - - - - - - -]]> - -
- -
- JPA based configuration (<jpaconfiguration>) - - A <jpaconfiguration> - is used when you want to read the metamodel from JPA/Hibernate Ann= otation where - you want to use the auto-scan configuration as defined in the JPA = spec (part of EJB3). In - other words, when you do not have a - hibernate.cfg.xml, but instead have a setup where you use - a - persistence.xml - packaged in a JPA compliant manner. - - The <jpaconfiguration> - will simply just try and auto-configure it self based on the avail= able - classpath, e.g. look for - META-INF/persistence.xml.= - - The - persistenceunit - attribute can be used to select a specific persistence= unit. If no - persistenceunit - is specified it will automatically search for one and = if a unique one is found, - use it, but if multiple persistence units are available it will er= ror. - - To use a <jpaconfiguration> - you will need to specify some additional jars from Hibernate Enti= tyManager in - the <taskdef> of the hibernatetool. The followi= ng shows a full setup: - - - - - - - - = - - = - - - - - - - - - - - - -]]> - - - - Note: - ejb3configuration was the name used in previous versions. It= still works but will emit - a warning telling you to use jpaconfi= guration instead. - - -
- -
- JDBC Configuration for reverse engineering (<jdbcconfigura= tion>) - - A <jdbcconfiguration> is used to perform re= verse engineering of the database from a JDBC connection. - - This configuration works by reading the connection properties = either from - hibernate.cfg.xml - or - hibernate.properties - with a fileset. - - The <jdbcconfiguration> has the same attrib= utes as a = - <configuration> - plus the following additional attributes: - - - ... - ]]> - - - Jdbcconfiguration attributes - - - - - - - - - - - - - Attribute name - - Definition - - Attribute use - - - - - - - packagename - - - - The default package name to use when mappings for cl= asses are created - - - - Optional - - - - - - revengfile - - - - The name of a property file, e.g. "hibernate.propert= ies" - - - - Optional - - - - - - reversestrategy - - - - Name of a class that implements org.hibernate.cfg.re= veng.ReverseEngineeringStrategy. - Used for setting up the strategy the tools will use to c= ontrol the reverse engineering, e.g. naming of - properties, which tables to include/exclude etc. Using a= class instead of (or as - addition to) a reveng.xml file gives you full programmat= ic control of the reverse - engineering. - - - - Optional - - - - - - - detectManytoMany - - - - If true, tables which are pure many-to-many link tab= les will be mapped as - such. A pure many-to-many table is one which primary-key= contains exactly two - foreign-keys pointing to other entity tables and has no = other columns. - - - - Default: true - - - - - - detectOptimisticLock - - - - If true, columns named VERSION or TIMESTAMP with app= ropriate types will be - mapped with the appropriate optimistic locking correspon= ding to - <version> or <timestamp><= /code>. - - - - Default: true - - - - - - -
- -
- Example - - Here is an example of using <jdbcconfiguration><= /code> to generate Hibernate xml mappings via = - <hbm2hbmxml>. The connection settings here - is read from a - hibernate.properties - file but could just as well have been read from a - hibernate.cfg.xml. - - - - = - -]]> -
-
-
- -
- Exporters - - Exporters are the parts that do the actual job of converting the= hibernate metamodel into - various artifacts, mainly code. The following section describes the = current supported set of - exporters in the Hibernate Tool distribution. It is also possible for - userdefined exporters, that is done through the = - <hbmtemplate> - exporter. - -
- Database schema exporter (<hbm2ddl>) - - <hbm2ddl> lets you run schemaexport and sch= emaupdate which generates the appropriate SQL - DDL and allow you to store the result in a file or export it direc= tly to the database. - Remember that if a custom naming strategy is needed it is placed o= n the configuration - element. - - ]]> - - - Hbm2ddl exporter attributes - - - - - - - - - - - - - Attribute name - - Definition - - Attribute use - - - - - - - export - - - - Executes the generated statements against the databa= se - - - - Default: true - - - - - - update - - - - Try and create an update script representing the "de= lta" - between what is in the database and what the mappings sp= ecify. Ignores - create/update attributes. (Do *not* use agains= t production databases, no - guarantees at all that the proper delta can be generat= ed nor that the underlying - database can actually execute the needed operations). - - - - Default: false - - - - - - drop - - - - Output will contain drop statements for the tables, = indices and - constraints - - - - Default: false - - - - - - - create - - - - Output will contain create statements for the tables= , indices and - constraints - - - - Default: true - - - - - - outputfilename - - - - If specified the statements will be dumped to this f= ile - - - - Optional - - - - - - delimiter - - - - If specified the statements will be dumped to this f= ile - - - - Default: ";" - - - - - - format - - - - Apply basic formatting to the statements - - - - Default: false - - - - - - haltonerror - - - - Halt build process if an error occurs - - - - Default: false - - - - - -
- -
- Example - - Basic example of using <hbm2ddl>, which = does not export to the - database but simply dumps the sql to a file named - sql.ddl. - - - - -]]> -
-
- -
- POJO java code exporter (<hbm2java>) - - <hbm2java> is a java codegenerator. Options= for controlling whether JDK 5 syntax can be - used and whether the POJO should be annotated with EJB3/Hibernate = Annotations. - - ]]> - - - Hbm2java exporter attributes - - - - - - - - - - - - - Attribute name - - Definition - - Default value - - - - - - - jdk - - - - Code will contain JDK 5 constructs such as generics = and static imports - - - - False - - - - - - ejb3 - - - - Code will contain EJB 3 features, e.g. using annotat= ions from - javax.persistence and org.hibernate.annotations - - - - False - - - - - - -
- -
- Example - - Basic example of using <hbm2java> to gene= rate POJO's that utilize jdk5 constructs. - - - - -]]> -
-
- -
- Hibernate Mapping files exporter (<hbm2hbmxml>) - - <hbm2hbmxml> generates a set of .hbm files.= Intended to be used together with a = - <jdbcconfiguration> - when performing reverse engineering, but can be used with any kin= d of - configuration. e.g. to convert from annotation based pojo's to - hbm.xml. - - - Note: - Not every possible mapping transformation is possible/implem= ented (contributions - welcome) so some hand editing might be necessary. - - - ]]> - -
- Example - - Basic usage of <hbm2hbmxml>. - - - - -]]> - - <hbm2hbmxml> is normally used with a <jdbcconfiguration> like in the above example, but any other= configuration can also be used to - convert between the different ways of performing mappings. Here = is an example of that, - using an <annotationconfiguration> - . - - - Note: - Not all conversions are implemented (contributions welcome= ), so some hand editing - might be necessary. - - - - - -]]> -
-
- -
- Hibernate Configuration file exporter (<hbm2cfgxml>)</t= itle> - - <para><code><hbm2cfgxml></code> generates a <emphasis> - <property moreinfo=3D"none">hibernate.cfg.xml</property>. </emph= asis> Intended to be used together with a <code><jdbcconfiguration></= code> - when performing reverse engineering, but it can be used with any = kind of - configuration. The <code><hbm2cfgxml></code> will contain th= e properties used and adds mapping entries for each mapped class.</para> - - <programlisting format=3D"linespecific" role=3D"XML"><![CDATA[<hbm2c= fgxml - ejb3=3D"true|false" -/> -]]></programlisting> - - <table frame=3D"topbot"> - <title>Hbm2cfgxml exporter attribute - - - - - - - - - - - - - Attribute name - - Definition - - Default value - - - - - - - - ejb3 - - - - The generated cfg.xml will have <mapping class=3D= ".."/>, opposed - to <mapping resource=3D"..."/> for each mapping. - - - - False - - - - - - - - -
- -
- Documentation exporter (<hbm2doc>) - - <hbm2doc> - generates html documentation a'la javadoc for the database schema= et.al. - - ]]> -
- -
- Query exporter (<query>) - - <query> is used to execute a HQL query stat= ements and optionally sends the output to a - file. It can be used for verifying the mappings and for basic data= extraction. - - - [a HQL query string] - -]]> - - Currently one session is opened and used for all queries and t= he query is executed via - the list() method. In the future more options might become availab= le, like performing - executeUpdate(), use named queries and etc. - - - -
- Examples - - The simplest usage of <query> will just e= xecute the query without dumping to a file. This can be used to - verify that queries can actually be performed. - - - - from java.lang.Object -]]> - - Multiple queries can be executed by nested <hql>= elements. - In this example we also let the output be dumped to - queryresult.txt. - - - Note: - Currently the dump is simply a call to toString on each e= lement. - - - - - - select c.name from Customer c where c.age > 42 - from Cat -]]> - -
-
- -
- Generic Hibernate metamodel exporter (<hbmtemplate>)</t= itle> - - <para>Generic exporter that can be controlled by a user provides a t= emplate or class.</para> - - <programlisting format=3D"linespecific" role=3D"XML"><![CDATA[<hbmte= mplate - filepattern=3D"{package-name}/{class-name}.ftl" - template=3D"somename.ftl" - exporterclass=3D"Exporter classname" -/>]]></programlisting> - - <note> - <title>Note: - Previous versions of the tools used Velocity. We are now usi= ng Freemarker which - provides us much better exception and error handling. - - -
- Exporter via <hbmtemplate> - - The following is an example of reverse engineering via = - <jdbcconfiguration> and usage of a custom Exp= orter via the = - <hbmtemplate>. - - - = - = - = - - - = - - = - -]]> - -
-
- Relevant Resources Links - - Read more about V= elocity and Freemarker to find out why using the last is better - or refer to Max Andersen discussion on the topic in "A story about FreeMarker and Velocity". -
-
-
- - - -
- Using properties to configure Exporters - - Exporters can be controlled by user properties. The user propert= ies are specified via = - <property> - or = - <propertyset> - and each exporter will have access to them directly in the templat= es and via - Exporter.setProperties(). - -
- <property> and - <propertyset> - - The <property> = - allows you bind a string value to a key. The value will be availab= le in the - templates via $<key>. - The following example will assign the string value = - "true" - to the variable = - $descriptors - . - - ]]> - - Most times using <property> is enough for s= pecifying the properties needed for the exporters. Still the ant - tools supports the notion of <propertyset> that= is used for grouping a set of properties. More about the functionality of = <propertyset> - is explained in detail in the Ant - manual. -
- -
- Getting access to user specific classes - - If the templates need to access some user class it becomes pos= sible by specifying a - "toolclass" in the properties. - - -]]> - - Placing the above <property> tag in &= lt;hibernatetool> - or inside any exporter will automatically create an instance of - x.y.z.NameOfToolClass and i= t will be available in the templates as - $sometool. This is useful t= o delegate logic and code generation to java - code instead of placing such logic in the templates. - -
- Example - - Here is an example that uses <hbmtemplate> - together with <property> which will be availa= ble to the templates/exporter. - - Note: - This example actually simulates what <hbm2java&g= t; actually does. - - - - - - - - - -]]> -
-
-
-
- - = -.java - , - .hbm.xml - etc. - - To govern this process Hibernate uses a reverse engineering strategy. A - reverse engineering strategy is mainly called to provide more java lik= e names for tables, column - and foreignkeys into classes, properties and associations. It also use= d to provide mappings from - SQL types to Hibernate types. T= he strategy can be customized by a user. The - user can even provide its own custom reverse engineering strategy if t= he provided strategy is - not enough, or simply just provide a small part of the strategy and de= legate the rest to the - default strategy. - - Thus, further in this chapter we will discuss how you can configur= e the process of a reverse - engineering, what default reverse engineering strategy includes as well = as some custom concepts. - = -
- Default reverse engineering strategy - - The default strategy uses some rules for mapping JDBC artifact n= ames to java artifact - names. It also provide basic typemappings from JDBC types to Hibernate - types. It is the default strategy that uses the packagename attribut= e to convert a table name - to a fully qualified classname. -
- -
- hibernate.reveng.xml file - - To have fine control over the process a - hibernate.reveng.xml - file can be provided. In this file you can specify type = mappings and table - filtering. This file can be created by hand (it's just basic XML) or= you can use the - Hibernate plugins<= /ulink> which have a - specialized editor. - - - Note: - Many databases are case-sensitive with their names and thus if= you cannot make some - table match and you are sure it is not excluded by a <tab= le-filter> then check - if the case matches; most databases stores table names in uppercas= e. - - - Below you can see an example of a - reveng.xml. Fol= lowing the example gives you more details - about the format. - - - - - - - - - = - - - = - - = - - - - = - - - = - - - = - - - = - - - - seq_table - - - - - - - - - - - - - - -
- -
]]>
- - -
- Schema Selection (<schema-selection>) - - <schema-selection> is used to drive which s= chemas the reverse engineering will try and - process. - - By default the reverse engineering will read all schemas and t= hen use <table-filter> - to decide which tables get reverse engineered and which do not; th= is makes it - easy to get started but can be inefficient on databases with many = schemas. - - With <schema-selection> it is thus possible= to limit the actual processed schemas and thus significantly - speed-up the reverse engineering. <table-filter> is still used to then decide which tables will be included/excluded. - - - Note: - If no <schema-selection> is specified, th= e reverse - engineering works as if all schemas should be processed. This is= equal to: - ]]>. Which in turn is equal to: - ]]> - - -
- Examples - - The following will process all tables from - "MY_SCHEMA". - - - ]]> - - It is possible to have multiple s= chema-selection's to support - multi-schema reading or simply to limit the processing to very s= pecific tables. The - following example processes all tables in - "MY_SCHEMA", - a specific - "CITY" - table plus all tables that starts with - "CODES_" - in - "COMMON_SCHEMA". - - - - -]]> -
-
- -
- Type mappings (<type-mapping>) - - The <type-mapping> section specifies how th= e JDBC types found in the database should be mapped to - Hibernate types. e.g. - java.sql.Types.VARCHAR with a length of 1 should be mapped to the - Hibernate type - yes_no or - java.sql.Types.NUMERIC<= /emphasis> should generally just be - converted to the Hibernate type long. - - - -]]> - - The number of attributes specified and the sequence of the sql-type's - is important. Meaning that Hibernate will search for the most specific - first, and if no specific match is found it will seek from top to = bottom when trying to - resolve a type mapping. - -
- Example - - The following is an example of a type-mapping which shows th= e flexibility and the - importance of ordering of the type mappings. - - - - - - - - - -]]> - - The following table shows how this affects an example table = named - CUSTOMER: - - - sql-type examples - - - - - - - - - - - - - - - - - - - Column - - jdbc-type - - length - - precision - - not-null - - Resulting hibernate-type - - Rationale - - - - - - ID - - INTEGER - - - - 10 - - true - - int - - Nothing is defined for INTEGER. Falling back to def= ault behavior. - - - - NAME - - VARCHAR - - 30 - - - - false - - your.package.TrimStringUserType - - No type-mapping matches length=3D30 and not-null=3D= false, but type-mapping - matches the 2 mappings which only specifies VARCHAR. The= type-mapping that comes - first is chosen. - - - - INITIAL - - VARCHAR - - 1 - - - - false - - char - - Even though there is a generic match for VARCHAR, t= he more specific - type-mapping for VARCHAR with not-null=3D"false" is chos= en. The first VARCHAR - sql-type matches in length but has no value for not-null= and thus is not - considered. - - - - CODE - - VARCHAR - - 1 - - - - true - - java.lang.Character - - The most specific VARCHAR with not-null=3D"true" is= selected - - - - SALARY - - NUMERIC - - - - 15 - - false - - big_decimal - - There is a precise match for NUMERIC with precision= 15 - - - - AGE - - NUMERIC - - - - 3 - - false - - java.lang.Long - - type-mapping for NUMERIC with not-null=3D"false" - - - -
- - -
-
- -
- Table filters (<table-filter>) - - The <table-filter> - let you specify matching rules for performing general filtering/se= tup for - tables, e.g. let you include or exclude specific tables based on t= he schema or even a - specific prefix. - - ]]> - = - - Table-filter attributes - = - - = - = - = - - = - - = - = - - - Attribute name - = - Definition - = - Default value - - - = - - - match-catalog - = - Pattern for matching catalog part of the tabl= e - = - .* - - = - - match-schema - = - Pattern for matching schema part of the table= - = - .* - - = - - match-table - = - Pattern for matching table part of the table<= /para> - = - .* - - = - - exclude - = - If true the table will not be part of the rev= erse - engineering - = - false - - = - - package - = - The default package name to use for classes b= ased on tables - matched by this table-filter - = - "" - - - = - -
- = -
- -
- Specific table configuration (<table>) - - <table> - allows you to provide explicit configuration on how a table should= be reverse - engineered. Amongst other things it allows controlling over the na= ming of a class for the - table, specifying which identifier generator should be used for th= e primary key etc. - - - - - - ]]> - = - - Table attributes - = - - = - = - = - - = - - = - = - - - Attribute name - = - Definition - = - Attribute use - - - = - - - catalog - = - Catalog name for a table. It has to be specifie= d if you are - reverse engineering multiple catalogs or if it is not equa= l to - hiberante.default_catalog. - = - Optional - - = - - schema - = - Schema name for a table. It has to be specified= if you are - reverse engineering multiple schemas or if it is not equal= to - hiberante.default_schema. - = - Optional - - = - - name - = - Name for a table. - = - Required - - = - - class - = - The class name for a table. Default name is a c= amelcase version - of the table name. - = - Optional - - = - - = - -
= - -
- <primary-key> - - A <primary-key> allows you to define a pr= imary-key for tables that don't have it - defined in the database, and probably more importantly it allows= you to define which - identifier strategy should be used (even for already existing pr= imary-key's). - - - parameter value - - - ]]> - = - - Primary-key attributes - = - - = - = - = - - = - - = - = - - - Attribute name - = - Definition - = - Attribute use - - - = - - - generator/class - = - Defines which identifier generator should be = used. - The class name is any hibernate short hand name or fully= qualified class name for an - identifier strategy. - = - Optional - - = - - generator/param - = - Allows to specify which parameter with a name= and - value should be passed to the identifier generator. - = - Optional - - = - - key-column - = - Specifies which column(s ) the primary-key co= nsists of. A - key-column is same as column, but does not have the excl= ude property. - = - Optional - - = - - = - -
= - -
- -
- <column> - - With a <column> it is possible to explici= tly name the resulting property for a column. It is - also possible to redefine what jdbc and/or Hibernate type a colu= mn should be processed as - and finally it is possible to completely exclude a column from p= rocessing. - = - ]]> - - - Column attributes - = - - = - = - = - - = - - = - = - - - Attribute name - = - Definition - = - Attribute use - - - = - - - name - = - Column name - = - Required - - = - - jdbc-type - = - Which jdbc-type this column should be process= ed as. A - value from java.sql.Types, either numerical (93) or the = constant name - (TIMESTAMP). - = - Optional - - = - - type - = - Which hibernate-type to use for this specific= column - = - Optional - - = - = - - property - = - What property name will be generated for this - column - = - Optional - - = - - exclude - = - Set to true if this column should be ignored<= /para> - = - default: false - - = - - = - -
= - = -
- -
- <foreign-key> - - The <foreign-key> - has two purposes. One for allowing to define foreign-keys in da= tabases that - does not support them or does not have them defined in their sch= ema. Secondly, to allow - defining the name of the resulting properties (many-to-one, one-= to-one and one-to-many's). - = - - - - - - ]]> - - Foreign-key attributes - = - - = - = - = - - = - - = - = - - - Attribute name - = - Definition - = - Attribute use - - - = - - - constraint-name - = - Name of the foreign key constraint. Important= when - naming many-to-one, one-to-one and set. It is the constr= aint-name that is used to link the - processed foreign-keys with the resulting property names= . - = - Required - - = - - foreign-catalog - = - Name of the foreign table's catalog. (Only - relevant if you want to explicitly define a foreign key)= . - = - Optional - - = - - foreign-schema - = - Name of the foreign table's schema. (Only rel= evant - if you want to explicitly define a foreign key).<= /entry> - = - Optional - - = - = - - foreign-table - = - Name of the foreign table. (Only relevant if = you - want to explicitly define a foreign key). - = - Optional - - = - - column-ref - = - Defines that the foreign-key constraint betwe= en a - local-column and foreign-column name. (Only relevant if = you want to explicitly - define a foreign key). - = - Optional - - = - - many-to-one - = - Defines that a many-to-one should be created = and the - property attribute specifies the name of the resulting p= roperty. Exclude can be - used to explicitly define that it should be created or n= ot. - = - Optional - - = - - set - = - Defines that a set should be created based on= this foreign-key - and the property attribute specifies the name of the res= ulting (set) property. - Exclude can be used to explicitly define that it should = be created or not. - = - Optional - - = - - one-to-one - = - Defines that a one-to-one should be created a= nd the - property attribute specifies the name of the resulting p= roperty. Exclude can be - used to explicitly define that it should be created or n= ot. - = - Optional - - = - - inverse-one-to-one - = - Defines that an inverse one-to-one should be = created based on this foreign-key - and the property attribute specifies the name of the res= ulting property. - Exclude can be used to explicitly define that it should = be created or not. - = - Optional - - - = - -
= - = -
-
-
- -
- Custom strategy - - It is possible to implement a user strategy. Such strategy must = implement - org.hibernate.cfg.reveng.ReverseEngine= eringStrategy. - It is recommended that one uses the - DelegatingReverseEngineeringStrategy and provide a public constructor - which takes another ReverseEngineeringSt= rategy as an argument. This will - allow you to only implement the relevant methods and provide a fallb= ack strategy. Example of - custom delegating strategy which converts all column names that ends= with - "PK" - into a property named - "id". - - - -
- -
- Custom Database Metadata - - By default the reverse engineering is performed by reading using= the JDBC database - metadata API. This is done via the class - org.hibernate.cfg.reveng.dialect.JDBCM= etaDataDialect - which is an implementation of - org.hibernate.cfg.reveng.dialect.MetaD= ataDialect. - - - The default implementation can be replaced with an alternative i= mplementation by setting - the property - hibernatetool.metadatadialect - to a fully qualified classname for a class that implemen= ts - JDBCMetaDataDialect. - - This can be used to provide database specific optimized metadata= reading. If you create an - optimized/better metadata reading for your database it will be a ver= y welcome - contribution. -
-
- - = - - Controlling POJO code generation - - When using <hbm2java> or the eclipse plugin to = generate POJO java code you have the possibility to control - certain aspects of the code generation. This is primarily done with th= e <meta> - tag in the mapping files. The following section describes the possibl= e - <meta> - tags and their use. - -
- The <meta> attribute - - The <meta> tag is a simple way of annotating = the - hbm.xml - with information, so tools have a natural place to store= /read information that is - not directly related to the Hibernate core. - - You can use the <meta> tag to e.g. tell <hbm2java> - to only generate - "protected" - setters, have classes always implement a certain set of = interfaces or even have - them extend a certain base class and even more. - - The following example shows how to use various <meta>= ; - attributes and the resulting java code. - - - - Javadoc for the Person class - @author Frodo - - IAuditable - - protected - - - - The name of the person - -]]> - - The above - hbm.xml - will produce something like the following (code shortene= d for better - understanding). Notice the Javadoc comment and the protected set met= hods: - - - - - Supported meta tags - - - - - - - - - Attribute - - Description - - - - - - - class-description - - - inserted into the javadoc for classes - - - - - field-description - - - inserted into the javadoc for fields/properties - - - - - interface - - - If true, an interface is generated instead of an class.= - - - - - implements - - - interface the class should implement - - - - - extends - - - class that the current class should extend (ignored for= subclasses) - - - - - generated-class - - - overrule the name of the actual class generated - - - - - scope-class - - - scope for class - - - - - scope-set - - - scope for setter method - - - - - scope-get - - - scope for getter method - - - - - scope-field - - - scope for actual field - - - - - default-value - - - default initialization value for a field - - - - - use-in-tostring - - - include this property in the toString() - - - - - use-in-equals - - - include this property in the equals() and - hashCode() method. If= no use-in-equals is specified, no - equals/hashcode will be generated. - - - - - gen-property - - - property will not be generated if false (use with care)= - - - - - property-type - - - Overrides the default type of property. Use this with a= ny tag's to specify the - concrete type instead of just Object. - - - - - class-code - - - Extra code that will inserted at the end of the class - - - - - extra-import - - - Extra import that will inserted at the end of all other= imports - - - -
- - Attributes declared via the <meta> - tag are per default - "inherited" - inside an - hbm.xml - file. - - What does that mean? It means that if you e.g want to have all y= our classes implement - IAuditable then you just ad= d an <meta - attribute=3D"implements">IAuditable</meta> in the = top of the - hbm.xml - file, just after <hibernate-mapping>.= Now all classes defined - in that - hbm.xml - file will implement IAuditab= le! - - - Note: - This applies to all - <meta>-tags. Thus it can also e.g. be used to s= pecify that - all fields should be declare protected, instead of the default pri= vate. This is done by - adding <meta - attribute=3D"scope-field">protected</meta> at e.= g. just under - the <class> tag and all fields of that class wi= ll be - protected. - - - To avoid having a <meta> - tag inherited then you can simply specify inherit =3D "false= " - for the attribute, e.g. <meta attribute =3D "scope-class" = inherit =3D - "false">public abstract</meta> will restrict the <= emphasis> - "class-scope" - to the current class, not the subclasses. - -
- Recommendations - - The following are some good practices when using = - <meta> - attributes. - -
- Dangers of a class level <property moreinfo=3D"none">use-in= -string and use-in-equals</property> meta - attributes when having bi-directional associations - - If we have two entities with a bi-directional association be= tween them and define at - class scope level the meta attributes: - use-in-string, - - use-in-equals: - - - - true - true - ... - -]]> - - And for - Event.hbm - file: - - = - - true - true = - - - - - - - - - = - -]]> - - Then <hbm2java> - will assume you want to include all properties and collections i= n the - toString()/equals() methods and this can result i= n infinite - recursive calls. - - To remedy this you have to decide which side of the associat= ion will include the other - part (if at all) in the toString()/equals() methods= . Therefore it is - not a good practice to put at class scope such - meta - attributes, unless you are defining a class without = bi-directional - associations. - - We recommend instead to add the - meta - attributes at the property level: - - = - = - - true - - - - - true - true = - - - - - = - -]]> - - and now for Person: - - - - - Javadoc for the Person class - @author Frodo - - IAuditable - - protected - true = - - - - The name of the person - true - - -]]> -
- -
- Be aware of putting at class scope level <meta> - attributeuse-in-equals - - For equal()/hashCode() method generation, you h= ave to take into - account that the attributes that participate on such method defi= nition, should take into - account only attributes with business meaning (the name, social = security number, etc, but - no generated id's, for example). - - This is important because Java's hashbased collections, such= as - java.util.Set relies on= equals() and - hashcode() to be correc= t and not change for objects in the set; - this can be a problem if the id gets assigned for an object afte= r you inserted it into a - set. - - Therefore automatically configuration of the generation of - equals()/hashCode() met= hods specifying at class scope level the <meta> attribut= e - use-in-equals - could be a dangerous decision that could produce non= expected - side-effect. - - On www.hibe= rnate.org you can get more in-depth - explanation on the subject of equals= () and - hashcode(). -
-
- -
- Advanced <meta> attribute examples - - This section shows an example for using meta attributes (inclu= ding userspecific - attributes) together with the code generation features in Hibernate - Tools. - - The usecase being implemented is to automatically insert some = pre- and post-conditions - into the getter and setters of the generated POJO. - -
- Generate pre/post-conditions for methods - - With a <meta attribute=3D"class-code">, = you can add - additional methods on a given class, nevertheless such <= ;meta> - attribute can not be used at a property scope level and Hibernate - Tools does not provide such - ><meta> - attributes. - - A possible solution for this is to modify the freemarker tem= plates responsible for - generating the POJO's. If you look inside - hibernate-tools.jar, you can find the template: - pojo/PojoPropertyAccessor.ftl - - - This file is as the name indicates used to generate property= accessors for - pojo's. - - Extract the - PojoPropertyAccessor.ftl - into a local folder i.e. - ${hbm.template.path}, <= /emphasis> respecting the whole path, for - example: - ${hbm.template.path}/pojo/PojoProp= ertyAccessor.ftl - - - The contents of the file is something like this: - - - ${pojo.getPropertyGetModifiers(property)} = - ${pojo.getJavaTypeName(property, jdk5)} = - ${pojo.getGetterSignature(property)}() { - return this.${property.name}; - } - = - ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyNa= me(property)} - (${pojo.getJavaTypeName(property, jdk5)} ${property.name}) = - { - this.${property.name} =3D ${property.name}; - } -]]> - - We can add conditionally pre/post-conditions on our set method - generation just adding a little Freemarker syntax to the above s= ource code: - - - ${pojo.getPropertyGetModifiers(property)} = - ${pojo.getJavaTypeName(property, jdk5)} = - ${pojo.getGetterSignature(property)}() - { - return this.${property.name}; - } - = - ${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyNa= me(property)} - (${pojo.getJavaTypeName(property, jdk5)} ${property.name}) = - { - <#if pojo.hasMetaAttribute(property, "pre-cond")> = - ${c2j.getMetaAsString(property, "pre-cond","\n")} = - = - this.${property.name} =3D ${property.name}; - <#if pojo.hasMetaAttribute(property, "post-cond")> = - ${c2j.getMetaAsString(property, "post-cond","\n")} = - = -} -]]> - - - Now if in any - .hbm.xml - file we define the - <meta> - attributes: pre-cond or post-cond= , their - contents will be generated into the body of the relevant set - method. - - As an example let us add a pre-condition for property = name - preventing no Person can = have an empty name. Hence we have to modify - the - Person.hbm.xml - file like this: - - - - = - - - - - if ((firstName !=3D null) && (firstName.length() =3D=3D 0) )= { - throw new IllegalArgumentException("firstName can not be an empty = String"); - } - - - -]]> - - - Note: - I) To escape the & symbol we put &amp;. You can use - <![CDATA[]]> instead. - II) Note that we are referring to "firstName" directly and= this is the parameter - name not the actual field name. If you want to refer the field= you have to use - "this.firstName" instead. - - - Finally we have to generate the - Person.java - class, for this we can use both Eclipse and Ant as l= ong as you remember to set - or fill in the templatepath setting. For Ant we configure = <hibernatetool> - task via the templatepath = attribute as in: - - - - - - - = - - - - - - - - ]]> - - Invoking the target <hbm2java> - will generate on the - ${hbm2java.dest.dir} - the file - Person.java - : - - - - In conclusion, this document is intended to introduce you to= Hibernate plugin specific - features related to tools bath for the Eclipse and Ant tasks. - - In the Eclipse Plugins chap= ter you've learnt - about a set of wizards for creating Mapping files, Configuration= file, Console - Configuration, got familiar with Mapping and Configuration files= editors, tooling for - organizing and controlling Reverse Engineering, Hibernate Consol= e and Mapping diagram as - well. - - The rest chapters have shown the aspects of using the Hibernate - Tools via Ant tasks. - Please, visit JBoss - Tools Users Forum to leave questions or/and suggestions = on the topic. Your - feedback is always appreciated. -
-
- -
- - - = - = - = -
Modified: trunk/hibernatetools/docs/reference/en-US/plugins.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/hibernatetools/docs/reference/en-US/plugins.xml 2011-03-02 22:58:= 02 UTC (rev 29454) +++ trunk/hibernatetools/docs/reference/en-US/plugins.xml 2011-03-02 23:34:= 47 UTC (rev 29455) @@ -2,29 +2,29 @@ Eclipse Plugins - This chapter will introduce you to the set of wizards and editors provid= ed by Hibernate Tools within Eclipse to simplify= working with Hibernate. + This chapter will introduce you to the set of wizards and editors provid= ed by Hibernate Tools within Eclipse, which are = designed to simplify working with Hibernate.
Introduction - Hibernate Eclipse Tools includes wizards for creating Hibernate mapping= files, configuration files (.cfg.xml), reve= nge.xml files as well as wizards for adjusting Console Configura= tion and Code Generation. Special structured and XML editors, and editors f= or executing HQL and Criteria queries are also provided in Hibernate Consol= e. Refer to to find all the bene= fits that are provided by these tools within Eclipse. + Hibernate Eclipse Tools includes wizards for creating Hibernate mapping= files, configuration files (.cfg.xml), reve= nge.xml files as well as wizards for adjusting Console Configura= tion and Code Generation. Special structured and XML editors and editors fo= r executing HQL and Criteria queries are also provided in Hibernate Console= . Refer to to find all the benef= its that are provided by these tools within Eclipse. Note: - Please note that these tools do not try to hide any of Hi= bernates functionality; rather the tools make working with Hibernate easier. You are still encouraged to read= the Hibernate Documentation= in order to be able to fully utilize Hibernate Tools<= /productname> and especially Hibernate it self. + Please note that these tools do not try to hide any of Hi= bernates functionality; rather the tools make working with Hibernate easier. You are still encouraged to read= the Hibernate Documentation in order to be able to fully utilize Hibernate Tools and especially Hibernate itself.
Download base project You can download the example projects that are used in this chapt= er. - A JPA base project is available on the documentation resources page together with a base Java project. + A JPA base project is available on the documentation resources page together with a base Java project. Also you need start the database. Note: - The steps for running the database are documented in the Getting Started Guide. + The steps for running the database are documented in the Getting Started Guide.
@@ -32,7 +32,7 @@ Creating a Hibernate Mapping File Hibernate mapping files are used to specify how your objects relat= e to database tables. - To create basic mappings for properties and associations, i. e. generat= e .hbm.xml files, Hibernate Tools provide a basic wiza= rd which you can display by selecting New + To create basic mappings for properties and associations, i. e. generat= e .hbm.xml files, Hibernate Tools provide a basic wiza= rd which you can display by selecting FileNew Hibernate XML mapping file . @@ -262,9 +262,7 @@ - - Options - for the optional settings + The Options tab the optional settings
@@ -301,7 +299,7 @@ Database dialect - Define a database dialect. It is possible either to write yo= ur value or choose from list. + Define a database dialect. It is possible either to enter yo= ur own value or choose from list. No default value @@ -312,7 +310,7 @@ Naming strategy - Fully qualified classname of a custom NamingStrategy. Only r= equired if you use a special naming strategy. + Fully qualified classname of a custom NamingStrategy. Only required if you use a special naming strategy. No default value @@ -323,7 +321,7 @@ Entity resolver - Fully qualified classname of a custom EntityResolver. Only r= equired if you have special XML entity includes in your mapping files. + Fully qualified classname of a custom EntityResolver. Only required if you have special XML entity includes in your mappin= g files. No default value @@ -511,7 +509,7 @@
- The following table describes the available settings in the Properties view. Most properties can be changed by left clicki= ng on them but some are not. = + The following table describes the available settings in the Properties view. Most properties can be changed by left clicki= ng on them, but some can not. = Properties @@ -624,7 +622,7 @@
Closing Hibernate Console Configuration - To close Hibernate Console Configuration you need= to right-click your configuration and choose the Close Config= uration option + To close Hibernate Console Configuration you need= to right-click your configuration and choose the Close Config= uration option.
Close Hibernate Console Configuration @@ -642,7 +640,7 @@
Reverse Engineering and Code Generation - Hibernate provides "click-and-generate" reverse engineering a= nd code generation facilities. This allows you to generate a range of artif= acts based on database or an already existing Hibernate configuration, be t= hat mapping files or annotated classes. Some of these are POJO Java source = files, Hibernate .hbm.xml, hibernate.cfg.xml= generation and schema documentation. + Hibernate provides "click-and-generate" reverse engineering a= nd code generation facilities. This allows you to generate a range of artif= acts based on database or an existing Hibernate configuration, be that mapp= ing files or annotated classes. Some of these are POJO Java source files, H= ibernate .hbm.xml files, hibernate.cfg.xml generation and schema documentation. To start working with this process, start the Hibernate Code = Generation tool which is available from the toolbar via the Hibernate icon or via the RunHibernate Code Generation= menu item. @@ -681,7 +679,7 @@ Tip: - The "At least one exporter option must be selected" warning= is just stating that for this launch to work you need to select an exporte= r on the Exporter tab. When an exporter has been selec= ted the warning will disappear. + The "At least one exporter option must be selected" warning= indicates that for this launcher to work you need to select an exporter on= the Exporter tab. When an exporter has been selected = the warning will disappear. @@ -710,7 +708,7 @@ Console Configuration - The name of the console configuration which should be used w= hen generating code + The name of the console configuration that should be used wh= en generating code @@ -729,7 +727,7 @@ - If enabled, the tools will reverse engineer the database availabl= e via the connection information in the selected Hibernate Console Configur= ation, and generate code based on the database schema. If not enabled, the = code generation will just be based on the mappings already specified in the= Hibernate Console configuration. + If enabled, the tools will reverse engineer the database defined = in the connection information in the selected Hibernate Console Configurati= on, and generate code based on the database schema. If not enabled, the cod= e generation will be based on the existing mappings specified in the Hibern= ate Console configuration. @@ -747,7 +745,7 @@ - Path to a reveng.xml file. A reven= g.xml file allows you to control certain aspects of the reverse = engineering such as how JDBC types are mapped to Hibernate types, and which= tables are included and excluded from the process (which is especially imp= ortant). Clicking the Setup button allows you to sel= ect an existing reveng.xml file or create a new one. S= ee more details about the reveng.xml file in . + Path to a reveng.xml file. A reven= g.xml file allows you to control certain aspects of the reverse = engineering process such as how JDBC types are mapped to Hibernate types, a= nd which tables are included and excluded from the process (which is especi= ally important). Clicking the Setup button allows yo= u to select an existing reveng.xml file, or create a n= ew one. See more details about the reveng.xml file in = . @@ -757,7 +755,7 @@ - If the reveng.xml file does not provide enou= gh customization you can provide your own implementation of a ReverseEngine= eringStrategy. The class needs to be in the classpath of the Console Config= uration, otherwise you will get class not found exceptions. See for details and an example of a custom stra= tegy. + If the reveng.xml file does not provide enou= gh customization you can provide your own implementation of a Reverse= EngineeringStrategy. The class needs to be in the classpath of the C= onsole Configuration, otherwise you will get class not found exceptions. Se= e for details and an example of = a custom strategy. @@ -767,7 +765,7 @@ - When a table that has a multi-column primary key a <comp= osite-id> mapping will always be created. If this option is enabl= ed and there are matching foreign-keys each key column is still considered = a 'basic' scalar (string, long, etc.) instead of a reference to an entity. = If you disable this option a <key-many-to-one> instead. = Note: a <many-to-one> property is still created, but is = simply marked as non-updatable and non-insertable. + When a table that has a multi-column primary key a <comp= osite-id> mapping will always be created. If this option is enabl= ed and there are matching foreign-keys, each key column is still considered= a 'basic' scalar (string, long, etc.) instead of a reference to an entity.= If you disable this option a <key-many-to-one> instead.= Note: a <many-to-one> property is still created, but is= simply marked as non-updatable and non-insertable. @@ -798,7 +796,7 @@ Reverse engineering detects one-to-one associations via primary k= ey and both the hbm.xml file and annotation generation= generates the proper code for it. = - The detection is enabled by default (except for Seam 1.2 and Seam= 2.0) reverse engineering. For Hibernate Tools generation there is a checkb= ox to disable if not wanted. = + The detection is enabled by default (except for Seam 1.2 and Seam= 2.0) reverse engineering. For Hibernate Tools generation there is a checkb= ox to disable this feature if it is not required. = @@ -889,7 +887,7 @@ - Generate a hibernate.cfg.xml file. Used to k= eep the hibernate.cfg.xml update with any new found ma= pping files. + Generate a hibernate.cfg.xml file. Used to k= eep the hibernate.cfg.xml file updated with any newly = discovered mapping files. --===============5725373306654171274==--