The Artima Developer Community
Sponsored Link

Java Buzz Forum
Hibernate3 Example of Annotation Hell :)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Hibernate3 Example of Annotation Hell :) Posted: Jul 8, 2005 8:52 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Hibernate3 Example of Annotation Hell :)
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement

I am getting to play with Hibernate 3, and they have done a nice job. I was poking around the Caveat Emptor example from Hibernate in Action, which was updated for Hibernate3.

I happened across this file: package-info.java:

@TypeDefs({
	@TypeDef(
		name="monetary_amount_usd",
		typeClass = MonetaryAmountType.class,
		parameters = { @Parameter(name="convertTo", value="USD") }
	),
	@TypeDef(
		name="monetary_amount_eur",
		typeClass = MonetaryAmountType.class,
		parameters = { @Parameter(name="convertTo", value="EUR") }
	),
	@TypeDef(
		name="item_state",
		typeClass = EnumUserType.class,
		parameters = { @Parameter(name="enumClassName", value="org.hibernate.ce.auction.model.ItemState") }
	),

    @TypeDef(
        name="creditcard_type",
        typeClass = EnumUserType.class,
        parameters = { @Parameter(name="enumClassName", value="org.hibernate.ce.auction.model.CreditCardType") }
    ),
    @TypeDef(
        name="rating",
        typeClass = EnumUserType.class,
        parameters = { @Parameter(name="enumClassName", value="org.hibernate.ce.auction.model.Rating") }
    )
})

@NamedQueries({
    @NamedQuery(
        name="minBid",
        queryString="select b from Bid b where b.amount.value = (select min(b.amount.value) from Bid b where b.item.id = :itemid)"
    ),
    @NamedQuery(
        name="maxBid",
        queryString="select b from Bid b where b.amount.value = (select max(b.amount.value) from Bid b where b.item.id = :itemid)"
    )
})

package org.hibernate.ce.auction.persistence;

import org.hibernate.annotations.*;
import javax.persistence.*;

Is this better than XML? To have this code sucked in?

NOTE: You don't have to use the annotations of course.

Read: Hibernate3 Example of Annotation Hell :)

Topic: ActiveGrid - where’s the business? Previous Topic   Next Topic Topic: Fixed Podcast Feed

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use