Update of /cvsroot/xdoclet/xdoclet/samples/src/java/test/hibernate
In directory sc8-pr-cvs1:/tmp/cvs-serv1742

Modified Files:
        CompositeId.java Order.java 
Added Files:
        Animal.java Contraband.java Human.java ImportedProduct.java 
        LineItem.java Lizard.java Name.java Persistent.java Pet.java 
        Product.java 
Removed Files:
        BaseReferenceValue.java ItemTypeRefValue.java OrderItems.java 
        OrderItems2.java OrderTypeRefValue.java 
Log Message:
brand new hibernate examples

--- NEW FILE: Animal.java ---
package test.hibernate;

import java.util.Set;

/**
 * @author Administrator
 *
 * @hibernate.class
 *  table="ANIMALS"
 *  dynamic-update="true"
 */
public class Animal extends Persistent {
        
        private Set prey;
        private char sex;

        /**
         * Constructor for Animal.
         */
        public Animal() {
                super();
        }

        /**
         * @hibernate.set
         *  lazy="true"
         *  table="PREDATOR_PREY"
         *  order-by="PREY_ID"
         * @hibernate.collection-key
         *  column="PREDATOR_ID"
         * @hibernate.collection-many-to-many
         *  column="PREY_ID"
         * @return Set
         */
        public Set getPrey() {
                return prey;
        }

        /**
         * Sets the prey.
         * @param prey The prey to set
         */
        public void setPrey(Set prey) {
                this.prey = prey;
        }

        /**
         * @hibernate.property
         *  not-null="true"
         * Returns the sex.
         * @return char
         */
        public char getSex() {
                return sex;
        }

        /**
         * Sets the sex.
         * @param sex The sex to set
         */
        public void setSex(char sex) {
                this.sex = sex;
        }

}

--- NEW FILE: Contraband.java ---
package test.hibernate;

/**
 * @author Administrator
 *
 * @hibernate.subclass
 *  discriminator-value="contraband"
 */
public class Contraband extends ImportedProduct {

        /**
         * Constructor for Contraband.
         */
        public Contraband() {
                super();
        }

}

--- NEW FILE: Human.java ---
package test.hibernate;

/**
 * @author Administrator
 *
 * @hibernate.joined-subclass
 *  table="HUMANS"
 *  dynamic-update="true"
 * @hibernate.joined-subclass-key
 *  column="ANIMAL_ID"
 */
public class Human extends Animal {

        private Name name;
        private String occupation;

        /**
         * Constructor for Human.
         */
        public Human() {
                super();
        }
        
        /**
         * @hibernate.component
         * Returns the name.
         * @return Name
         */
        public Name getName() {
                return name;
        }

        /**
         * Sets the name.
         * @param name The name to set
         */
        public void setName(Name name) {
                this.name = name;
        }

        /**
         * @hibernate.property
         * Returns the occupation.
         * @return String
         */
        public String getOccupation() {
                return occupation;
        }

        /**
         * Sets the occupation.
         * @param occupation The occupation to set
         */
        public void setOccupation(String occupation) {
                this.occupation = occupation;
        }

}

--- NEW FILE: ImportedProduct.java ---
package test.hibernate;

import java.util.Locale;

/**
 * @author Administrator
 *
 * @hibernate.subclass
 *  discriminator-value="imported"
 */
public class ImportedProduct extends Product {
        
        private String origin;
        private Locale locale;

        /**
         * Constructor for ImportedProduct.
         */
        public ImportedProduct() {
                super();
        }

        /**
         * @hibernate.property
         *  not-null="true"
         * Returns the origin.
         * @return String
         */
        public String getOrigin() {
                return origin;
        }

        /**
         * Sets the origin.
         * @param origin The origin to set
         */
        public void setOrigin(String origin) {
                this.origin = origin;
        }

        /**
         * @hibernate.property
         * @return Locale
         */
        public Locale getLocale() {
                return locale;
        }

        /**
         * Sets the locale.
         * @param locale The locale to set
         */
        public void setLocale(Locale locale) {
                this.locale = locale;
        }

}

--- NEW FILE: LineItem.java ---
package test.hibernate;
/**
 * @hibernate.class
 *  table="ITEMS"
 *  mutable="false"
 *  schema="SHOP"
 *  proxy="LineItem"
 * 
 * @author Administrator
 *
 */
public class LineItem extends Persistent {
        
        private Order order;
        private Product product;
        private int quantity;

        /**
         * Constructor for LineItem.
         */
        public LineItem() {
                super();
        }

        /**
         * @hibernate.many-to-one
         *  outer-join="true"
         *  cascade="save-update"
         * @hibernate.column
         *  name="ORDER_ID"
         *  not-null="true"
         *  sql-type="BIGINT"
         * @return Order
         */
        public Order getOrder() {
                return order;
        }

        /**
         * Sets the order.
         * @param order The order to set
         */
        public void setOrder(Order order) {
                this.order = order;
        }

        /**
         * @hibernate.property
         *  column="AMOUNT"
         *  not-null="true"
         *  unique="false"
         * Returns the quantity.
         * @return int
         */
        public int getQuantity() {
                return quantity;
        }

        /**
         * Sets the quantity.
         * @param quantity The quantity to set
         */
        public void setQuantity(int quantity) {
                this.quantity = quantity;
        }

        /**
         * @hibernate.many-to-one
         *  column="PRODUCT_ID"
         *  outer-join="true"
         *  not-null="true"
         * @return Product
         */
        public Product getProduct() {
                return product;
        }

        /**
         * Sets the product.
         * @param product The product to set
         */
        public void setProduct(Product product) {
                this.product = product;
        }

}

--- NEW FILE: Lizard.java ---
package test.hibernate;

/**
 * @author Administrator
 *
 * @hibernate.joined-subclass
 *  table="LIZARDS"
 * @hibernate.joined-subclass-key
 *  column="ANIMAL_ID"
 */
public class Lizard extends Animal {
        
        private float bodyTemperature;

        /**
         * Constructor for Lizard.
         */
        public Lizard() {
                super();
        }

        /**
         * @hibernate.property
         *  not-null="true"
         * @return float
         */
        public float getBodyTemperature() {
                return bodyTemperature;
        }

        /**
         * Sets the bodyTemperature.
         * @param bodyTemperature The bodyTemperature to set
         */
        public void setBodyTemperature(float bodyTemperature) {
                this.bodyTemperature = bodyTemperature;
        }

}

--- NEW FILE: Name.java ---
package test.hibernate;

/**
 * @author Administrator
 *
 */
public class Name {

        private String first;
        private char initial;
        private String last;

        /**
         * @hibernate.property
         *  column="FIRST_NAME"
         * Returns the first.
         * @return String
         */
        public String getFirst() {
                return first;
        }

        /**
         * @hibernate.property
         * @hibernate.column 
         *  name="INITIAL" 
         *  sql-type="VARCHAR(1)"
         *  not-null="true"
         * Returns the initial.
         * @return char
         */
        public char getInitial() {
                return initial;
        }

        /**
         * @hibernate.property
         *  column="LIST_NAME"
         * @return String
         */
        public String getLast() {
                return last;
        }

        /**
         * Sets the first.
         * @param first The first to set
         */
        public void setFirst(String first) {
                this.first = first;
        }

        /**
         * Sets the initial.
         * @param initial The initial to set
         */
        public void setInitial(char initial) {
                this.initial = initial;
        }

        /**
         * Sets the last.
         * @param last The last to set
         */
        public void setLast(String last) {
                this.last = last;
        }

}

--- NEW FILE: Persistent.java ---
package test.hibernate;

import java.util.Date;

/**
 * @author Administrator
 */
public abstract class Persistent {
        
        private Long id;
        private int version;
        private Date created;

        /**
         * Constructor for Persistent.
         */
        public Persistent() {
                super();
        }

        /**
         * @hibernate.id
         *  unsaved-value="null"
         *  generator-class="sequence"
         * @hibernate.generator-parameter
         *  name="table"
         *  value="HIVAL"
         * @hibernate.generator-parameter
         *  name="column"
         *  value="NEXT"
         * @return Long
         */
        public Long getId() {
                return id;
        }

        /**
         * Sets the id.
         * @param id The id to set
         */
        public void setId(Long id) {
                this.id = id;
        }

        /**
         * @hibernate.version
         * @return int
         */
        public int getVersion() {
                return version;
        }

        /**
         * Sets the version.
         * @param version The version to set
         */
        public void setVersion(int version) {
                this.version = version;
        }
        
        /**
         * @hibernate.property
         *  update="false"
         *  insert="true"
         *  type="timestamp"
         * Returns the created.
         * @return Date
         */
        public Date getCreated() {
                return created;
        }

        /**
         * Sets the created.
         * @param created The created to set
         */
        public void setCreated(Date created) {
                this.created = created;
        }

}

--- NEW FILE: Pet.java ---
package test.hibernate;

/**
 * @author Administrator
 *
 * @hibernate.subclass
 *  table="PETS"
 *  discriminator-value="pet"
 */
public class Pet extends Product {

        private Animal animal;

        /**
         * Constructor for Pet.
         */
        public Pet() {
                super();
        }

        /**
         * @hibernate.one-to-one
         * @return Animal
         */
        public Animal getAnimal() {
                return animal;
        }

        /**
         * Sets the animal.
         * @param animal The animal to set
         */
        public void setAnimal(Animal animal) {
                this.animal = animal;
        }

}

--- NEW FILE: Product.java ---
package test.hibernate;

import java.math.BigDecimal;

/**
 * @hibernate.class
 *  table="PRODUCTS"
 *  discriminator-value="null"
 *  dynamic-update="true"
 * @hibernate.discriminator
 *  column="PRODUCT_TYPE"
 *  type="string"
 *  length="16"
 *  not-null="false"
 * @hibernate.jcs-cache
 *  usage="read-only"
 * 
 * @author Administrator
 */
public class Product extends Persistent {
        
        private String description;
        private String code;
        private BigDecimal price;
        private byte[] image;

        /**
         * Constructor for Product.
         */
        public Product() {
                super();
        }

        /**
         * @hibernate.property
         *  length="512"
         * @return String
         */
        public String getDescription() {
                return description;
        }

        /**
         * Sets the name.
         * @param name The name to set
         */
        public void setDescription(String name) {
                this.description = name;
        }

        /**
         * @hibernate.property
         *  length="16"
         *  unique="true"
         *  update="false"
         * @return String
         */
        public String getCode() {
                return code;
        }

        /**
         * Sets the code.
         * @param code The code to set
         */
        public void setCode(String code) {
                this.code = code;
        }

        /**
         * @hibernate.property
         *  length="4096"
         * Returns the image.
         * @return byte[]
         */
        public byte[] getImage() {
                return image;
        }

        /**
         * @hibernate.property
         * Returns the price.
         * @return BigDecimal
         */
        public BigDecimal getPrice() {
                return price;
        }

        /**
         * Sets the image.
         * @param image The image to set
         */
        public void setImage(byte[] image) {
                this.image = image;
        }

        /**
         * Sets the price.
         * @param price The price to set
         */
        public void setPrice(BigDecimal price) {
                this.price = price;
        }

}

Index: CompositeId.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/samples/src/java/test/hibernate/CompositeId.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** CompositeId.java    7 Jan 2003 14:24:19 -0000       1.2
--- CompositeId.java    15 Mar 2003 06:00:43 -0000      1.3
***************
*** 119,121 ****
--- 119,126 ----
  
      }
+ 
+     public int hashCode()
+     {
+               return _baz.hashCode();
+       }
  }

Index: Order.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/samples/src/java/test/hibernate/Order.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Order.java  9 Mar 2003 07:50:55 -0000       1.2
--- Order.java  15 Mar 2003 06:00:44 -0000      1.3
***************
*** 1,196 ****
! /*
!  * Copyright (c) 2001, 2002 The XDoclet team
!  * All rights reserved.
!  */
! package test.hibernate;
! 
! import java.util.Collections;
! import java.util.Date;
! import java.util.Set;
! 
! /**
!  * Order Sample
!  *
!  * @author                sguimont
!  * @created               06 December 2002
!  * @hibernate.class       table="TB_ORDER"
!  * @hibernate.jcs-cache   usage="read-write"
!  * @hibernate.query       name="query1" query="select a from b for pleasure 1"
!  * @hibernate.query       name="query2" query="select a from b for pleasure 2"
!  */
! public class Order
! {
!     private Date    created;
!     private String  orderNumber;
!     private long    id;
!     private double  total;
!     private OrderTypeRefValue orderType;
!     private int     version;
!     private Set     items = Collections.EMPTY_SET;
!     private OrderItems2 items2;
! 
!     /**
!      * Returns the created.
!      *
!      * @return               Date
!      * @hibernate.property   column="DT_CREATED"
!      */
!     public Date getCreated()
!     {
!         return created;
!     }
! 
!     /**
!      * Returns the id.
!      *
!      * @return         long
!      * @hibernate.id   column="ID" generator-class="vm.long"
!      */
!     public long getId()
!     {
!         return id;
!     }
! 
!     /**
!      * Returns the orderNumber.
!      *
!      * @return               String
!      * @hibernate.property   column="ORDER_NUMBER"
!      */
!     public String getOrderNumber()
!     {
!         return orderNumber;
!     }
! 
!     /**
!      * Returns the total.
!      *
!      * @return               double
!      * @hibernate.property   column="TOTAL"
!      */
!     public double getTotal()
!     {
!         return total;
!     }
! 
!     /**
!      * Returns the orderType.
!      *
!      * @return                  OrderTypeRefValue
!      * @hibernate.many-to-one   column="ORDER_TYPE_CD" cascade="none"
!      */
!     public OrderTypeRefValue getOrderType()
!     {
!         return orderType;
!     }
! 
!     /**
!      * Returns the version.
!      *
!      * @return              int
!      * @hibernate.version   column="VER"
!      */
!     public int getVersion()
!     {
!         return version;
!     }
! 
!     /**
!      * Returns the items.
!      *
!      * @return                                   Set
!      * @hibernate.set                            role="items" table="TB_ORDER_ITEM"
!      * @hibernate.collection-key                 column="ORDER_ID"
!      * @hibernate.collection-composite-element   class="test.hibernate.OrderItems"
!      */
!     public Set getItems()
!     {
!         return items;
!     }
! 
!     /**
!      * Returns the items.
!      *
!      * @return                Set
!      * @hibernate.component
!      */
!     public OrderItems2 getOrderItems2()
!     {
!         return items2;
!     }
! 
!     /**
!      * Sets the created.
!      *
!      * @param created  The created to set
!      */
!     public void setCreated(Date created)
!     {
!         this.created = created;
!     }
! 
!     /**
!      * Sets the id.
!      *
!      * @param id  The id to set
!      */
!     public void setId(long id)
!     {
!         this.id = id;
!     }
! 
!     /**
!      * Sets the orderNumber.
!      *
!      * @param orderNumber  The orderNumber to set
!      */
!     public void setOrderNumber(String orderNumber)
!     {
!         this.orderNumber = orderNumber;
!     }
! 
!     /**
!      * Sets the total.
!      *
!      * @param total  The total to set
!      */
!     public void setTotal(double total)
!     {
!         this.total = total;
!     }
! 
!     /**
!      * Sets the orderType.
!      *
!      * @param orderType  The orderType to set
!      */
!     public void setOrderType(OrderTypeRefValue orderType)
!     {
!         this.orderType = orderType;
!     }
! 
!     /**
!      * Sets the version.
!      *
!      * @param version  The version to set
!      */
!     public void setVersion(int version)
!     {
!         this.version = version;
!     }
! 
!     public void setOrderItems2(OrderItems2 items2)
!     {
!         this.items2 = items2;
!     }
! 
!     /**
!      * Sets the items.
!      *
!      * @param items  The items to set
!      */
!     public void setItems(Set items)
!     {
!         this.items = items;
!     }
! }
--- 1,92 ----
! package test.hibernate;
! 
! import java.util.Calendar;
! import java.util.List;
! 
! /**
!  * @author Administrator
!  *
!  * @hibernate.jcs-cache
!  *  usage="read-write"
!  * @hibernate.class
!  *  table="ORDERS"
!  *  polymorphism="explicit"
!  *  mutable="false"
!  */
! public class Order extends Persistent {
!       
!       private List items;
!       private Human customer;
!       private Calendar date;
! 
!       /**
!        * Constructor for Order.
!        */
!       public Order() {
!               super();
!       }
! 
!       /**
!        * @hibernate.list
!        *  lazy="true"
!        *  inverse="true"
!        *  cascade="all"
!        * @hibernate.jcs-cache
!        *  usage="read-write"
!        * @hibernate.collection-key
!        *  column="ORDER_ID"
!        * @hibernate.collection-index
!        *  column="ORDER_POS"
!        * @hibernate.collection-one-to-many
!        *  class="test.hibernate.LineItem"
!        * @return List
!        */
!       public List getItems() {
!               return items;
!       }
! 
!       /**
!        * Sets the items.
!        * @param items The items to set
!        */
!       public void setItems(List items) {
!               this.items = items;
!       }
! 
!       /**
!        * @hibernate.property
!        *  type="calendar_date"
!        * Returns the date.
!        * @return Calendar
!        */
!       public Calendar getDate() {
!               return date;
!       }
! 
!       /**
!        * Sets the date.
!        * @param date The date to set
!        */
!       public void setDate(Calendar date) {
!               this.date = date;
!       }
! 
!       /**
!        * @hibernate.many-to-one
!        *  column="CUSTOMER_ID"
!        *  not-null="true"
!        * @return Human
!        */
!       public Human getCustomer() {
!               return customer;
!       }
! 
!       /**
!        * Sets the customer.
!        * @param customer The customer to set
!        */
!       public void setCustomer(Human customer) {
!               this.customer = customer;
!       }
! 
! }

--- BaseReferenceValue.java DELETED ---

--- ItemTypeRefValue.java DELETED ---

--- OrderItems.java DELETED ---

--- OrderItems2.java DELETED ---

--- OrderTypeRefValue.java DELETED ---



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to