本文整理汇总了Java中org.hibernate.internal.util.ReflectHelper类的典型用法代码示例。如果您正苦于以下问题:Java ReflectHelper类的具体用法?Java ReflectHelper怎么用?Java ReflectHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReflectHelper类属于org.hibernate.internal.util包,在下文中一共展示了ReflectHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseIdentifierGeneratorRegistration
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private static void parseIdentifierGeneratorRegistration(Element element, Mappings mappings) {
String strategy = element.attributeValue( "name" );
if ( StringHelper.isEmpty( strategy ) ) {
throw new MappingException( "'name' attribute expected for identifier-generator elements" );
}
String generatorClassName = element.attributeValue( "class" );
if ( StringHelper.isEmpty( generatorClassName ) ) {
throw new MappingException( "'class' attribute expected for identifier-generator [[email protected]=" + strategy + "]" );
}
try {
Class generatorClass = ReflectHelper.classForName( generatorClassName );
mappings.getIdentifierGeneratorFactory().register( strategy, generatorClass );
}
catch ( ClassNotFoundException e ) {
throw new MappingException( "Unable to locate identifier-generator class [name=" + strategy + ", class=" + generatorClassName + "]" );
}
}
示例2: addTargetClass
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
String className = element.attributeValue( nodeName );
if ( className != null ) {
Class clazz;
try {
clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( className, defaults ), this.getClass()
);
}
catch ( ClassNotFoundException e ) {
throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + className, e
);
}
ad.setValue( getJavaAttributeNameFromXMLOne( nodeName ), clazz );
}
}
示例3: getMapKeyClass
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private void getMapKeyClass(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
String nodeName = "map-key-class";
Element subelement = element != null ? element.element( nodeName ) : null;
if ( subelement != null ) {
String mapKeyClassName = subelement.attributeValue( "class" );
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyClass.class );
if ( StringHelper.isNotEmpty( mapKeyClassName ) ) {
Class clazz;
try {
clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( mapKeyClassName, defaults ),
this.getClass()
);
}
catch ( ClassNotFoundException e ) {
throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e
);
}
ad.setValue( "value", clazz );
}
annotationList.add( AnnotationFactory.create( ad ) );
}
}
示例4: bindNamedSubgraph
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private static void bindNamedSubgraph(XMLContext.Default defaults, AnnotationDescriptor ann, List<Element> subgraphNodes) {
List<NamedSubgraph> annSubgraphNodes = new ArrayList<NamedSubgraph>( );
for(Element subgraphNode : subgraphNodes){
AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
copyStringAttribute( annSubgraphNode, subgraphNode, "name", true );
String clazzName = subgraphNode.attributeValue( "class" );
Class clazz;
try {
clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( clazzName, defaults ),
JPAOverriddenAnnotationReader.class
);
}
catch ( ClassNotFoundException e ) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
}
annSubgraphNode.setValue( "type", clazz );
bindNamedAttributeNodes(subgraphNode, annSubgraphNode);
annSubgraphNodes.add( (NamedSubgraph) AnnotationFactory.create( annSubgraphNode ) );
}
ann.setValue( "subgraphs", annSubgraphNodes.toArray( new NamedSubgraph[annSubgraphNodes.size()] ) );
}
示例5: getElementClass
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
public Class getElementClass() throws MappingException {
if (elementClassName==null) {
org.hibernate.type.Type elementType = getElement().getType();
return isPrimitiveArray() ?
( (PrimitiveType) elementType ).getPrimitiveClass() :
elementType.getReturnedClass();
}
else {
try {
return ReflectHelper.classForName(elementClassName);
}
catch (ClassNotFoundException cnfe) {
throw new MappingException(cnfe);
}
}
}
示例6: getConfiguration
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private Configuration getConfiguration() throws Exception {
Configuration cfg = new Configuration();
if (namingStrategy!=null) {
cfg.setNamingStrategy(
(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
);
}
if (configurationFile != null) {
cfg.configure( configurationFile );
}
String[] files = getFiles();
for (int i = 0; i < files.length; i++) {
String filename = files[i];
if ( filename.endsWith(".jar") ) {
cfg.addJar( new File(filename) );
}
else {
cfg.addFile(filename);
}
}
return cfg;
}
示例7: getConfiguration
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private Configuration getConfiguration() throws Exception {
Configuration cfg = new Configuration();
if (namingStrategy!=null) {
cfg.setNamingStrategy(
(NamingStrategy) ReflectHelper.classForName( namingStrategy ).newInstance()
);
}
if (configurationFile!=null) {
cfg.configure( configurationFile );
}
String[] files = getFiles();
for (int i = 0; i < files.length; i++) {
String filename = files[i];
if ( filename.endsWith(".jar") ) {
cfg.addJar( new File(filename) );
}
else {
cfg.addFile(filename);
}
}
return cfg;
}
示例8: getConfiguration
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private Configuration getConfiguration() throws Exception {
Configuration cfg = new Configuration();
if (namingStrategy!=null) {
cfg.setNamingStrategy(
(NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
);
}
if (configurationFile!=null) {
cfg.configure( configurationFile );
}
String[] files = getFiles();
for (int i = 0; i < files.length; i++) {
String filename = files[i];
if ( filename.endsWith(".jar") ) {
cfg.addJar( new File(filename) );
}
else {
cfg.addFile(filename);
}
}
return cfg;
}
示例9: PojoInstantiator
import org.hibernate.internal.util.ReflectHelper; //导入依赖的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;
}
}
示例10: postInstantiate
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
@Override
public void postInstantiate(
final String entityName,
final Class persistentClass,
final Set interfaces,
final Method getIdentifierMethod,
final Method setIdentifierMethod,
CompositeType componentIdType) throws HibernateException {
this.entityName = entityName;
this.persistentClass = persistentClass;
this.interfaces = (Class[]) interfaces.toArray(NO_CLASSES);
this.getIdentifierMethod = getIdentifierMethod;
this.setIdentifierMethod = setIdentifierMethod;
this.componentIdType = componentIdType;
this.factory = JavassistLazyInitializer.getProxyFactory( persistentClass, this.interfaces );
this.overridesEquals = ReflectHelper.overridesEquals(persistentClass);
}
示例11: getIdentifierGeneratorClass
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
@Override
public Class getIdentifierGeneratorClass(String strategy) {
if ( "native".equals( strategy ) ) {
return dialect.getNativeIdentifierGeneratorClass();
}
Class generatorClass = generatorStrategyToClassNameMap.get( strategy );
try {
if ( generatorClass == null ) {
generatorClass = ReflectHelper.classForName( strategy );
}
}
catch ( ClassNotFoundException e ) {
throw new MappingException( String.format( "Could not interpret id generator strategy [%s]", strategy ) );
}
return generatorClass;
}
示例12: setProperties
import org.hibernate.internal.util.ReflectHelper; //导入依赖的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;
}
示例13: locateOracleTypesClass
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
private Class locateOracleTypesClass() {
try {
return ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME );
}
catch (ClassNotFoundException e) {
try {
return ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME );
}
catch (ClassNotFoundException e2) {
throw new HibernateException(
String.format(
"Unable to locate OracleTypes class using either known FQN [%s, %s]",
ORACLE_TYPES_CLASS_NAME,
DEPRECATED_ORACLE_TYPES_CLASS_NAME
),
e
);
}
}
}
示例14: lookupConstant
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
public void lookupConstant(DotNode node) throws SemanticException {
String text = ASTUtil.getPathText( node );
Queryable persister = walker.getSessionFactoryHelper().findQueryableUsingImports( text );
if ( persister != null ) {
// the name of an entity class
final String discrim = persister.getDiscriminatorSQLValue();
node.setDataType( persister.getDiscriminatorType() );
if ( InFragment.NULL.equals( discrim ) || InFragment.NOT_NULL.equals( discrim ) ) {
throw new InvalidPathException(
"subclass test not allowed for null or not null discriminator: '" + text + "'"
);
}
// the class discriminator value
setSQLValue( node, text, discrim );
}
else {
Object value = ReflectHelper.getConstantValue( text );
if ( value == null ) {
throw new InvalidPathException( "Invalid path: '" + text + "'" );
}
setConstantValue( node, text, value );
}
}
示例15: customCollection
import org.hibernate.internal.util.ReflectHelper; //导入依赖的package包/类
/**
* @deprecated Use {@link #customCollection(String, java.util.Properties, String, String)}
* instead.
* See Jira issue: <a href="https://hibernate.onjira.com/browse/HHH-7771">HHH-7771</a>
*/
@Deprecated
public CollectionType customCollection(
String typeName,
Properties typeParameters,
String role,
String propertyRef,
boolean embedded) {
Class typeClass;
try {
typeClass = ReflectHelper.classForName( typeName );
}
catch ( ClassNotFoundException cnfe ) {
throw new MappingException( "user collection type class not found: " + typeName, cnfe );
}
CustomCollectionType result = new CustomCollectionType( typeScope, typeClass, role, propertyRef, embedded );
if ( typeParameters != null ) {
injectParameters( result.getUserType(), typeParameters );
}
return result;
}