本文整理汇总了Java中org.hibernate.PropertyNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java PropertyNotFoundException类的具体用法?Java PropertyNotFoundException怎么用?Java PropertyNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyNotFoundException类属于org.hibernate包,在下文中一共展示了PropertyNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PojoInstantiator
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
this.mappedClass = component.getComponentClass();
this.isAbstract = ReflectHelper.isAbstractClass( mappedClass );
this.optimizer = optimizer;
this.proxyInterface = null;
this.embeddedIdentifier = false;
try {
constructor = ReflectHelper.getDefaultConstructor(mappedClass);
}
catch ( PropertyNotFoundException pnfe ) {
LOG.noDefaultConstructor(mappedClass.getName());
constructor = null;
}
}
示例2: setProperties
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public Query setProperties(Object bean) throws HibernateException {
Class clazz = bean.getClass();
String[] params = getNamedParameters();
for (int i = 0; i < params.length; i++) {
String namedParam = params[i];
try {
Getter getter = ReflectHelper.getGetter( clazz, namedParam );
Class retType = getter.getReturnType();
final Object object = getter.get( bean );
if ( Collection.class.isAssignableFrom( retType ) ) {
setParameterList( namedParam, ( Collection ) object );
}
else if ( retType.isArray() ) {
setParameterList( namedParam, ( Object[] ) object );
}
else {
setParameter( namedParam, object, determineType( namedParam, retType ) );
}
}
catch (PropertyNotFoundException pnfe) {
// ignore
}
}
return this;
}
示例3: getDefaultConstructor
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
/**
* Retrieve the default (no arg) constructor from the given class.
*
* @param clazz The class for which to retrieve the default ctor.
* @return The default constructor.
* @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???)
*/
public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws PropertyNotFoundException {
if ( isAbstractClass( clazz ) ) {
return null;
}
try {
Constructor<T> constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE );
constructor.setAccessible( true );
return constructor;
}
catch ( NoSuchMethodException nme ) {
throw new PropertyNotFoundException(
"Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor"
);
}
}
示例4: getConstructor
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
/**
* Retrieve a constructor for the given class, with arguments matching the specified Hibernate mapping
* {@link Type types}.
*
* @param clazz The class needing instantiation
* @param types The types representing the required ctor param signature
* @return The matching constructor.
* @throws PropertyNotFoundException Indicates we could not locate an appropriate constructor (todo : again with PropertyNotFoundException???)
*/
public static Constructor getConstructor(Class clazz, Type[] types) throws PropertyNotFoundException {
final Constructor[] candidates = clazz.getConstructors();
for ( int i = 0; i < candidates.length; i++ ) {
final Constructor constructor = candidates[i];
final Class[] params = constructor.getParameterTypes();
if ( params.length == types.length ) {
boolean found = true;
for ( int j = 0; j < params.length; j++ ) {
final boolean ok = params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
types[j] instanceof PrimitiveType &&
params[j] == ( ( PrimitiveType ) types[j] ).getPrimitiveClass()
);
if ( !ok ) {
found = false;
break;
}
}
if ( found ) {
constructor.setAccessible( true );
return constructor;
}
}
}
throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
示例5: extractPrimaryKeyValue
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public String extractPrimaryKeyValue(){
//Get pk column and value
String pkValue = null;
try{
pkValue = pc.getIdentifierProperty().getGetter(entity.getClass()).get(entity).toString();
} catch(PropertyNotFoundException pnfe) {
logger.info("PropertyNotFoundException " + pnfe.getMessage());
} catch(MappingException me) {
logger.info("MappingException " + me.getMessage());
} catch(HibernateException he) {
logger.info("HibernateException " + he.getMessage());
} catch(NullPointerException npe) {
logger.info("NullPointerException " + npe.getMessage());
}
return pkValue;
}
示例6: getGetter
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
/**
* Create a "getter" for the named attribute
*/
public Getter getGetter(Class theClass, String propertyName)
throws PropertyNotFoundException {
if (nodeName==null) {
throw new MappingException("no node name for property: " + propertyName);
}
if ( ".".equals(nodeName) ) {
return new TextGetter(propertyType, factory);
}
else if ( nodeName.indexOf('/')>-1 ) {
return new ElementAttributeGetter(nodeName, propertyType, factory);
}
else if ( nodeName.indexOf('@')>-1 ) {
return new AttributeGetter(nodeName, propertyType, factory);
}
else {
return new ElementGetter(nodeName, propertyType, factory);
}
}
示例7: getSetter
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
/**
* Create a "setter" for the named attribute
*/
public Setter getSetter(Class theClass, String propertyName)
throws PropertyNotFoundException {
if (nodeName==null) {
throw new MappingException("no node name for property: " + propertyName);
}
if ( ".".equals(nodeName) ) {
return new TextSetter(propertyType);
}
else if ( nodeName.indexOf('/')>-1 ) {
return new ElementAttributeSetter(nodeName, propertyType);
}
else if ( nodeName.indexOf('@')>-1 ) {
return new AttributeSetter(nodeName, propertyType);
}
else {
return new ElementSetter(nodeName, propertyType);
}
}
示例8: PojoInstantiator
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public PojoInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) {
this.mappedClass = component.getComponentClass();
this.optimizer = optimizer;
this.proxyInterface = null;
this.embeddedIdentifier = false;
try {
constructor = ReflectHelper.getDefaultConstructor(mappedClass);
}
catch ( PropertyNotFoundException pnfe ) {
log.info(
"no default (no-argument) constructor for class: " +
mappedClass.getName() +
" (class must be instantiated by Interceptor)"
);
constructor = null;
}
}
示例9: getDefaultConstructor
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException {
if ( isAbstractClass(clazz) ) return null;
try {
Constructor constructor = clazz.getDeclaredConstructor(NO_CLASSES);
if ( !isPublic(clazz, constructor) ) {
constructor.setAccessible(true);
}
return constructor;
}
catch (NoSuchMethodException nme) {
throw new PropertyNotFoundException(
"Object class " + clazz.getName() +
" must declare a default (no-argument) constructor"
);
}
}
示例10: getConstructor
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public static Constructor getConstructor(Class clazz, Type[] types) throws PropertyNotFoundException {
final Constructor[] candidates = clazz.getConstructors();
for ( int i=0; i<candidates.length; i++ ) {
final Constructor constructor = candidates[i];
final Class[] params = constructor.getParameterTypes();
if ( params.length==types.length ) {
boolean found = true;
for ( int j=0; j<params.length; j++ ) {
final boolean ok = params[j].isAssignableFrom( types[j].getReturnedClass() ) || (
types[j] instanceof PrimitiveType &&
params[j] == ( (PrimitiveType) types[j] ).getPrimitiveClass()
);
if (!ok) {
found = false;
break;
}
}
if (found) {
if ( !isPublic(clazz, constructor) ) constructor.setAccessible(true);
return constructor;
}
}
}
throw new PropertyNotFoundException( "no appropriate constructor in class: " + clazz.getName() );
}
示例11: getDefaultConstructor
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
/**
* Retrieve the default (no arg) constructor from the given class.
*
* @param clazz The class for which to retrieve the default ctor.
* @return The default constructor.
* @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???)
*/
public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException {
if ( isAbstractClass( clazz ) ) {
return null;
}
try {
Constructor constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE );
if ( !isPublic( clazz, constructor ) ) {
constructor.setAccessible( true );
}
return constructor;
}
catch ( NoSuchMethodException nme ) {
throw new PropertyNotFoundException(
"Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor"
);
}
}
示例12: globalErrorHandler
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
@ExceptionHandler(value =
{
Exception.class,
NullPointerException.class,
NoSuchRequestHandlingMethodException.class,
RuntimeException.class,
ResourceAccessException.class,
AccessDeniedException.class,
PropertyNotFoundException.class,
ConstraintViolationException.class,
NestedServletException.class}
)
// Don't pass model object here. Seriously was creating issues here.
public ModelAndView globalErrorHandler(HttpServletRequest request, Exception e) {
System.out.println("comes in exception controller");
ModelAndView mdlViewObj = new ModelAndView("/common/Exception");
logger.error(e.getStackTrace());
return mdlViewObj;
//return new ModelAndView("common/Exception"); // Error java.lang.IllegalStateException: No suitable resolver for argument [0] [type=org.springframework.ui.ModelMap]
}
示例13: createSetter
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
private static Setter createSetter(Class theClass, String propertyName) throws PropertyNotFoundException {
BasicSetter result = getSetterOrNull(theClass, propertyName);
if (result==null) {
throw new PropertyNotFoundException(
"Could not find a setter for property " +
propertyName +
" in class " +
theClass.getName()
);
}
return result;
}
示例14: createGetter
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
public static Getter createGetter(Class theClass, String propertyName) throws PropertyNotFoundException {
BasicGetter result = getGetterOrNull(theClass, propertyName);
if (result==null) {
throw new PropertyNotFoundException(
"Could not find a getter for " +
propertyName +
" in class " +
theClass.getName()
);
}
return result;
}
示例15: getField
import org.hibernate.PropertyNotFoundException; //导入依赖的package包/类
private static Field getField(Class clazz, String name) throws PropertyNotFoundException {
if ( clazz==null || clazz==Object.class ) {
throw new PropertyNotFoundException("field not found: " + name);
}
Field field;
try {
field = clazz.getDeclaredField(name);
}
catch (NoSuchFieldException nsfe) {
field = getField( clazz, clazz.getSuperclass(), name );
}
field.setAccessible(true);
return field;
}