Hi
I'm using Java Persistence with Hibernate and annotations in a standard J2SE application.
The issue I have is that it is taking 3-4 seconds to initialise everything in hibernate when I start the application. Nothing is hitting the DB at this point.
I've got about 60 entities in my application (and this is likely to grow).
So at startup, I get lots of entries like this as it processes the entities and annotations:
Code:
FINE [org.hibernate.cfg.annotations.SimpleValueBinder]: building SimpleValue for attachmentPath
FINE [org.hibernate.cfg.annotations.PropertyBinder]: Building property attachmentPath
FINE [org.hibernate.cfg.AnnotationBinder]: Processing annotations of com.categoric.businesslayer.entities.FTPAttachment.module
FINE [org.hibernate.cfg.Ejb3Column]: Binding column ModuleID unique false
FINE [org.hibernate.cfg.Ejb3Column]: Binding column module unique false
And then I get a load more entries like this (not sure what it is doing at this point - building prepared statements?):
Code:
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Static SQL for entity: com.categoric.businesslayer.entities.TextFormat
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Version select: select ModuleID from Module where ModuleID =?
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Snapshot select: select textformat_.ModuleID, textformat_.name as name2_, textformat_.AdminXMLID as AdminXMLID2_, textformat_.AlertProfileID as AlertPro8_2_, textformat_.description as descript4_2_, textformat_.GraphLayoutID as GraphLay7_2_, textformat_.ModuleID2 as ModuleID5_2_, textformat_.ServerXMLID as ServerXM6_2_, textformat_.ServiceID as ServiceID2_, textformat_1_.MessageSection as MessageS1_60_, textformat_1_.TextFormatID as TextForm2_60_ from Module textformat_ left outer join TextFormat textformat_1_ on textformat_.ModuleID=textformat_1_.ModuleID where textformat_.ModuleID=?
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Insert 0: insert into Module (name, AdminXMLID, AlertProfileID, description, GraphLayoutID, ModuleID2, ServerXMLID, ServiceID, ModuleTypeID, ModuleID) values (?, ?, ?, ?, ?, ?, ?, ?, 6, ?)
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Update 0: update Module set name=?, AdminXMLID=?, AlertProfileID=?, description=?, GraphLayoutID=?, ModuleID2=?, ServerXMLID=?, ServiceID=? where ModuleID=?
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Delete 0: delete from Module where ModuleID=?
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Insert 1: insert into TextFormat (MessageSection, TextFormatID, ModuleID) values (?, ?, ?)
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Update 1: update TextFormat set MessageSection=?, TextFormatID=? where ModuleID=?
FINE [org.hibernate.persister.entity.AbstractEntityPersister]: Delete 1: delete from TextFormat where ModuleID=?
Is it possible to get hibernate to cache any of this information from previous runs of the application? Would going back to using XML mappings files be faster than using annotations? Any ideas on what I can do to remove this startup time. This is a big issue to me as this is a desktop RCP application so the user experience isn't good.
TIA
Ian