Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Hibernation & ANT

Options
  • 13-07-2009 4:09pm
    #1
    Moderators, Education Moderators, Technology & Internet Moderators, Regional South East Moderators Posts: 24,056 Mod ✭✭✭✭


    I'm looking for someone who is good with Hibernation and ANT to help me out a little. Currently preparing for a repeat exam and coming across a few roadblocks as my memory is falling short on parts. The topics are Hibernation and ANT.

    Hibernation has me confused with DOM and DAO (seems simple enough question anyway) while parts of ANT has me completely confused (global property decelerations and resource collection decelerations).

    Its a third year exam (based on Java). Appreciate if any folk are able to guide me through the roadblocks and help clear up the confusion.


Comments

  • Registered Users Posts: 1,916 ✭✭✭ronivek


    You'd really need to be a bit more specific in terms of exactly what you're having trouble understanding.

    Hibernate is a framework that provides object persistence and retrieval; amongst other things. DOM is a convention or system for manipulating XML and is not a "part" of Hibernate so I'm not sure what you're trying to ask there.

    A DAO is a Data Access Object; which in the context of your question would utilise Hibernate to persist and retrieve objects. It's a pretty well known pattern and you can read more here; http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html.

    There's an absolute tonne of information online on everything you've mentioned so as stated above unless you can be really specific there's probably not a lot anyone here can do for you.


  • Moderators, Education Moderators, Technology & Internet Moderators, Regional South East Moderators Posts: 24,056 Mod ✭✭✭✭Sully


    Thanks for getting back. Actually only posted about something basic to see if anyone out there was knowledgable enough on the topic before I went into detail. Not great with Java I must admit but working away on it anyway. Ant & Hibernation were two topics covered in the exam which I am just trying to get someone clear up a bit of confusion as most of the stuff on the net isnt aimed at people who don't quickly grasp it!

    One of the questions on the paper was;
    (a) Demonstrate your understanding by writing the Java code excerpt for the Car class - focus on the class properties; all methods can be ignored.
    <class name="Car" table="CARS">
    <id name="id"  coumn="id" type="long>
    <generator class="increment" />
    </id>
    <compontent name="type"  class="CarType">
    <property name="make" type="string" />
    <property name="model" type="string" />
    <property name="cc" type="float" />
    </component>
    
    <property name="regNo" type="string" />
    <propert name="milage" type="int" />
    <set name="previous owners" cascade="save-update">
    <key column="CAR" />
    <one-to-many class="Owner" />
    </set>
    
    <many-to-one name="assignedTo" class="salesman" not-null="true" /> 
    </class>
    

    Answer:
    Public class Car extendes CarType {
    private long id;
    private int milage;
    private int regNo;
    }
    
    public class CarType {
    private string make;
    private string model;
    private float cc;
    }
    

    (b) With reference to the above mapping docment, modify to incorproate the following DOM observations:

    - reNo property has a well defined structure; year, county number
    - Many cars may have the same car type stored in a separate table (CARTYPE). Records here would have a foreign key to a CARTYPE record
    - When a car record is deleted the previous owner should automatically be removed

    (c) Write a DAO code excerpt to illustrate the concept of lazy-loading.

    From looking at the lecture notes with examples, I am a tad unsure how to approach the DOM question as it seems to mention more about DAO. Iv given an attempt at what I thought was right which ill type up later today. Lots of code, just a bit unsure how to approach it.

    The ANT stuff is separate then above, but taking it a step at a time.


  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    Your reNo needs to be traversable, in order to determine the year and country number from one property. It is also stored as a string in your DB, I'm not sure mapping it to an int will work. Maybe it needs to be delimited or otherwise given a structure.

    For previous owners you will have a Set which can be accessed via the car class which will contain references to previous owners classes. The idea of lazy loading is to never load the previous owners into that set (which reflects the join table mapping cars to previous owners) until it is required (ie: It will be empty until you call car.PreviousOwners.get(id); Lazy loading can be setup via a property in your table configuration file.


  • Moderators, Education Moderators, Technology & Internet Moderators, Regional South East Moderators Posts: 24,056 Mod ✭✭✭✭Sully


    I'm not sure exactly how to implement the java for the regNo, due to the way it needs to be read. I'm not sure how complex the mapping file needs to be for this reference - would the usual set method not be correct;
    <set name="regNo" cascade="save update">
    <key column="CAR" />
    </set>
    

    As for part II. The first part (the relationship) I am unsure where it needs referencing in the mapping unless I am referring to a specific java method? That brings me onto the next part (new table) where I assume I modify the component tag for the class CarType to include the new database table (the config file I think needs tweaking also on this);
    table="CARTYPE"
    

    Somehow reference the foreign key (not sure does it be treated the same reference as a PKEY, gonna look into it a bit more) CARS.

    Part III seems adding a new reference method in my mapping modifying the cascade - this new method must also, I assume, be implemented in the java so that needs to be shown in the answer also. Am I right?


Advertisement