Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (C) 2012 Clarion Media, LLC
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.clarionmedia.infinitum.orm;

This interface provides an API for creating new instances of model classes from ORM query results. It's important to note that model classes must contain an empty, parameterless constructor in order for these methods to work since java.lang.Object construction is done using reflection. If no such constructor is present, a com.clarionmedia.infinitum.orm.exception.ModelConfigurationException will be thrown at runtime.

Author(s):
Tyler Treat
Version:
1.0 02/20/12
Since:
1.0
public interface ModelFactory {

Constructs a domain model instance and populates its fields from the given ResultSet. The precondition for this method is that the ResultSet is currently at the row to convert to an java.lang.Object from the correct table.

Parameters:
result the ResultSet containing the row to convert to an Object
modelClass the Class of the Object being instantiated
Returns:
a populated instance of the specified Class
Throws:
com.clarionmedia.infinitum.orm.exception.ModelConfigurationException if the specified model Class does not contain an empty constructor
com.clarionmedia.infinitum.exception.InfinitumRuntimeException if the model could not be instantiated
java.lang.IllegalArgumentException if the ModelFactory implementation cannot process the ResultSet type
	<T> T createFromResult(ResultSet resultClass<T> modelClass)
New to GrepCode? Check out our FAQ X