Git Product home page Git Product logo

recipes's Introduction

Hibernate Example
-----------------

WARNING: This example requires Java 5.0

This example demonstrates how a class can be mapped with Hibernate and still be treated as a normal Grails domain class. Including the ability to:

- Scaffold the domain class
- Validate Against constraints
- Access dynamic methods

The domain class in question can be found in "src/java/com/recipes/Recipe.java" and is mapped using the Hibernate annotation support.

In order for this to work the Grails data source has been configured to use a special GrailsAnnotationConfiguration instance at the line:

   def configClass = GrailsAnnotationConfiguration.class

This is only necessary if you use Hibernate annotations, with normal XML Hibernate mapping no extra configuration is needed.

The only remaining thing to be done is the "hibernate.cfg.xml" file is placed within the "hibernate" directory and contains a mapping for the class:


<hibernate-configuration>
    <session-factory>      
        <mapping package="com.recipes" />
        <mapping class="com.recipes.Recipe" />
    </session-factory>
</hibernate-configuration>

To run the example after installing Grails type:

grails upgrade
grails run-app

And then in your browser go to:

http://localhost:8080/recipes/recipe/list

recipes's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.