I have created a method which has arument as Integer to fetch the DB record from Db using hibernate. Now i have string type argument for the same scenario. Can i change that method signature to Serializable to support Integer and String. Are there any issues if I have Serializable as the method argument.?
public Object get(final Class classObject, final Serializable id)
throws PersistenceException {
LOGGER.debug(LOG_PREFIX + "get::Begin");
Object obj = this.runInSession(new PersistentUnitOfWork() {
public Object run() throws PersistenceException {
return getPersistenceContext().get(classObject, id);
}
});
LOGGER.debug(LOG_PREFIX + "get::End");
return obj;
}
any issue comes due to this?
If you are using Hibernate API, the get method of the session supports an id of type serializable. I do not expect any issue coming with this, if this is officially supported by the API
http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/Session.html#get(java.lang.Class,java.io.Serializable
What sense would it have to have such an API, if you could not use it?