• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mappings vs Annotations

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any significant improvement in SessionFactory Startup in using annotations over mappings?

I know there are a lot of factors that effect startup time such as complexity and length of the mapping, but because hibernate doesn't have to read in XML to map with annotations, I would guess that annotations are quicker overall.

Is this a false statement? Im trying to do some tests to find out, but because of WTP 0.7 and HibTools, im having difficulty right now. Just thought I'd ask the community.

Thanks in advance!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think there is much of a difference in speed. I think it is more of whether you want to manually make seperate XML mapping files, or include that with Annotations. Annotations use Inspection of the Java classes to make Objects that get created at startup, where of course XML uses an IO Reader to load the XML and create the objects.

Mark
 
Jonathan Huang
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did some tests, (finally got WTP and hibtools working).

The more mapping files you have the time it takes to startup is linear. Depending on the size and complexity of your mapping files.

In my tests I used 2 mappings. A small mapping file (25 lines), then a large one (125 lines). They weren't complex, just property tags mostly.

My annotated class was a rewrite of the small mapping file. I'd show you the code, but I am not permited to do so. Just think of them as <id> and <property> tags. No sets or collections.

As you can see below the mappings take a bit longer, but not by very much. But their times are a more steep startup.

Large Mappings:
Loading 1 file averaged 1850 millis
Loading 5 files averaged 2150 millis
Loading 10 files averaged 2550 millis
Loading 20 files averaged 3200 millis

Annotated Class:
Loading 1 file:
1) 2172 millis
2) 1906 millis
3) 1875 millis
4) 1750 millis
5) 2005 millis

Loading 5 files:
1) 1874 millis
2) 1922 millis
3) 2172 millis
4) 1905 millis
5) 2020 millis

Loading 10 files:
1) 2625 millis
2) 1938 millis
3) 1937 millis
4) 1937 millis
5) 2101 millis

Loading 20 files:
1) 2266 millis
2) 2093 millis
3) 2156 millis
4) 2109 millis
5) 2102 millis
[ July 24, 2006: Message edited by: Jonathan Huang ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the information about startup, it is good information to know.

Mark
[ July 28, 2006: Message edited by: Mark Spritzler ]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Annotations and Mappings both have their own disadvantages

annotations when the table names and field names have to be changed need

recompilation...when Mappings don't need that...
reply
    Bookmark Topic Watch Topic
  • New Topic