Hibernate ORM PersistentClass - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM PersistentClass class.

This code example shows how to use the following methods: getIdentifierProperty, getProperty, getPropertyClosureSpan
		assertEquals(3, project.getPropertyClosureSpan());		
		assertEquals("projectId", project.getIdentifierProperty().getName());
		 
		PersistentClass employee = localCfg.getClassMapping("Employee");
		 
		assertNotNull(employee.getProperty("worksOns"));
		assertNotNull("property should be renamed by reveng.xml", employee.getProperty("manager"));		
		assertPropertyNotExists( employee, "employees", "set should be excluded by reveng.xml" );
		Property setProperty = employee.getProperty("managedProjects");
		assertNotNull("should be renamed by reveng.xml", setProperty);
		 
		assertEquals("delete, update", setProperty.getCascade());
		 
		assertEquals(4, employee.getPropertyClosureSpan());
		assertEquals("id", employee.getIdentifierProperty().getName());
		 
		PersistentClass worksOn = localCfg.getClassMapping("WorksOn");
		 
		assertNotNull(worksOn.getProperty("project"));
		assertNotNull(worksOn.getProperty("employee"));

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getEntityName, getNodeName
		this.nodeName = entityName;
		this.entityName = entityName.substring(index+1);
	} 
 
	public void postInstantiate(PersistentClass pc) {
		this.nodeName =pc.getNodeName();
		this.entityName =pc.getEntityName();
	} 
 
	public HibernateProxy getProxy(final Serializable id,  final SessionImplementor session) {
		try { 
			return new CFCHibernateProxy(new CFCLazyInitializer(entityName, id, session));
		} 
		catch(Throwable t){
			return new CFCHibernateProxy(new CFCLazyInitializer(nodeName, id, session));
		} 
	} 
} 
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: setClassName, setMetaAttributes
		assertEquals( "should be interface which cannot have implements", null, 
				entityPOJOClass.getImplements() );
		assertEquals( "should be interface which cannot have implements", "", 
				entityPOJOClass.getImplementsDeclaration() );
 
		PersistentClass base = new RootClass();
		base.setClassName( "Base" );
 
		PersistentClass sub = new SingleTableSubclass( base );
		sub.setClassName( "Sub" );
 
		assertEquals( null, c2j.getPOJOClass(base).getExtends() );
		assertEquals( "Base", c2j.getPOJOClass(sub).getExtends() );
 
		Map m = new HashMap();
		MetaAttribute attribute = new MetaAttribute( "extends" );
		attribute.addValue( "x" );
		attribute.addValue( "y" );
		m.put( attribute.getName(), attribute );
		attribute = new MetaAttribute( "interface" );

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getIdentifier, getIdentifierProperty, getMappedClass, hasEmbeddedIdentifier, hasIdentifierMapper
				getConstructor(mappedEntity)
			); 
 
		if ( property == null ) {
			// this is a virtual id property... 
			return new IdentifierProperty(
			        type,
					mappedEntity.hasEmbeddedIdentifier(),
					mappedEntity.hasIdentifierMapper(),
					unsavedValue,
					generator
				); 
		} 
		else { 
			return new IdentifierProperty(
					property.getName(),
					property.getNodeName(),
					type,
					mappedEntity.hasEmbeddedIdentifier(),
					unsavedValue,

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getMetaAttribute, getProperty
 
	@Test
	@TestForIssue( jiraKey = "HBX-718" ) 
	public void testNonMutatedInheritance() { 
		PersistentClass cm = cfg.getClassMapping("org.hibernate.test.legacy.Wicked");
		MetaAttribute metaAttribute = cm.getMetaAttribute( "globalmutated" );
		 
		assertNotNull(metaAttribute);
		/*assertEquals( metaAttribute.getValues().size(), 2 );		 
		assertEquals( "top level", metaAttribute.getValues().get(0) );*/ 
		assertEquals( "wicked level", metaAttribute.getValue() );
		 
		Property property = cm.getProperty( "component" );
		MetaAttribute propertyAttribute = property.getMetaAttribute( "globalmutated" );
		 
		assertNotNull(propertyAttribute);
		/*assertEquals( propertyAttribute.getValues().size(), 3 ); 
		assertEquals( "top level", propertyAttribute.getValues().get(0) ); 
		assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ 
		assertEquals( "monetaryamount level", propertyAttribute.getValue() );

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getVersion, isMutable, isVersioned
	public static CacheDataDescriptionImpl decode(Collection model) {
		return new CacheDataDescriptionImpl(
				model.isMutable(),
				model.getOwner().isVersioned(),
				model.getOwner().isVersioned() ? ( ( VersionType ) model.getOwner().getVersion().getType() ).getComparator() : null
		); 
	} 
 
	public static CacheDataDescriptionImpl decode(PluralAttributeBinding model) {
		return new CacheDataDescriptionImpl(
				model.isMutable(),
				model.getContainer().seekEntityBinding().isVersioned(),
				getVersionComparator( model.getContainer().seekEntityBinding() )
		); 
	} 
 
	private static Comparator getVersionComparator(EntityBinding model ) {
		Comparator versionComparator = null;
		if ( model.isVersioned() ) {
			versionComparator = (
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getProperty
	} 
 
	public void testMetaValueRead() throws Exception{
		Configuration config = getCfg();
		PersistentClass pc = config.getClassMapping("org.hibernate.tool.hbm2x.hbm2hbmxml.Person2");
		assertNotNull(pc);
		Property prop = pc.getProperty("data");
		assertNotNull(prop);
		assertTrue(prop.getValue() instanceof Any);
		Any any = (Any) prop.getValue();
		assertTrue("Expected to get one meta-value element", any.getMetaValues() != null);
		assertEquals("Expected to get one meta-value element", 1, any.getMetaValues().size());
 
	} 
 
	public void testMapManyToAny() throws DocumentException { 
		File outputXml = new File(getOutputDir(),  getBaseForMappings() + "PropertySet.hbm.xml");
		assertFileAndExists(outputXml);
 
		SAXReader xmlReader =  getSAXReader();
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getJpaEntityName, getMappedClass, getSuperMappedSuperclass, getSuperclass, hasIdentifierProperty
	} 
 
	//TODO remove / reduce @SW scope 
	@SuppressWarnings( "unchecked" ) 
	private static EntityTypeImpl<?> buildEntityType(PersistentClass persistentClass, MetadataContext context) {
		final Class javaType = persistentClass.getMappedClass();
		context.pushEntityWorkedOn(persistentClass);
		final MappedSuperclass superMappedSuperclass = persistentClass.getSuperMappedSuperclass();
		AbstractIdentifiableType<?> superType = superMappedSuperclass == null
				? null 
				: locateOrBuildMappedsuperclassType( superMappedSuperclass, context );
		//no mappedSuperclass, check for a super entity 
		if (superType == null) {
			final PersistentClass superPersistentClass = persistentClass.getSuperclass();
			superType = superPersistentClass == null
					? null 
					: locateOrBuildEntityType( superPersistentClass, context );
		} 
		EntityTypeImpl entityType = new EntityTypeImpl(
				javaType,

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: getIdentifier, getIdentifierMapper, getIdentifierProperty
        // Xml mapping which will be used for relations 
        Element rel_id_mapping = new DefaultElement("properties"); 
        // Xml mapping which will be used for the primary key of the versions table 
        Element orig_id_mapping = new DefaultElement("composite-id"); 
 
        Property id_prop = pc.getIdentifierProperty();
        Component id_mapper = pc.getIdentifierMapper();
 
        // Checking if the id mapping is supported 
        if (id_mapper == null && id_prop == null) {
            return null; 
        } 
 
        SimpleIdMapperBuilder mapper;
        if (id_mapper != null) {
            // Multiple id 
 
            mapper = new MultipleIdMapper(((Component) pc.getIdentifier()).getComponentClassName());
            if (!addIdProperties(rel_id_mapping, (Iterator<Property>) id_mapper.getPropertyIterator(), mapper, false, audited)) {
                return null; 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods: nextSubclassId