Originally posted by Cameron McKenzie:
I'm just doing some hibernate, and was wondering what the naming conventions for data access objects were? Are getter methods perferred because we are essentially using a POJO paradigm?
For example:
When getting a record for a User object by primary key, what's the way to name that? With EJBs, it would be findByPrimaryKey(int key) or something? What would we use in a Hibernate app? get(int key)? getByPrimaryKey(int key)?
What about a full table request? EJBs would have a method called findAll(). What is it with Hibernate? I've seen a method called List used, but I don't like the fact that a method named list conflicts with the Hibernate Session's list() method. Do we call the method getAll()?
So, what are the conventions for:
Create Methods? ***Just call them create(argument list)?***
Delete Methods? ***Just call them delete?***
Update Methods? ***Just call them update?***
Finder/Getter Methods? ***retrive? get? find?***
Thanks,
-Cameron McKenzie
in the past i've used persist, get, and delete. my get method for objects requiring key is get<EntityName>(key). for example:
in cases where my hibernate mapping defines a composite key, i pass in an object that encapsulates the multiple attributes that form the key.
for find, what i've done in the past is pass a search object criteria to my finder method. for example:
my find method would then look something like
of course not all criteria may be specified so in my dao i would only use attributes in my EmployeeSearchCriteria object that has a value.
hope this makes sense.