AnnotationConfiguration addAnnotatedClass - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AnnotationConfiguration addAnnotatedClass method.

This code example shows how to use the following methods:addAnnotatedClass, buildSessionFactory
This code example shows how to use the following methods:addAnnotatedClass, setProperty, buildSessionFactory
		 
		new ExecuteContext(getOutputDir(), file, jars) {
			 
		   protected void execute() throws Exception {
			    
			   AnnotationConfiguration configuration = new AnnotationConfiguration();
				Class puppet = getUcl().loadClass( "org.hibernate.tool.hbm2x." + className );
				configuration.addAnnotatedClass( puppet );
				 
				configuration.setProperty( "hibernate.hbm2ddl.auto", "create-drop" );
				SessionFactory sf = configuration.buildSessionFactory();
				Session s = sf.openSession();
 
				Object puppetInst = puppet.newInstance();
				puppet.getMethod( "setName", new Class[]{String.class} ).invoke( puppetInst, new Object[]{"Barbie"} );
				 
				if(className.equals("Bungalow")) { // hack to avoid not-null execption
					puppet.getMethod("setMascot", new Class[] { puppet }).invoke( puppetInst, new Object[] { puppetInst } );
				} 
				 
6
CodeRank
This code example shows how to use the following methods:addAnnotatedClass, setNamingStrategy, buildSessionFactory
        if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
	} 
 
	public void testWithCustomNamingStrategy() throws Exception {
		try { 
			AnnotationConfiguration config = new AnnotationConfiguration();
			config.setNamingStrategy(new DummyNamingStrategy());
			config.addAnnotatedClass(Address.class);
			config.addAnnotatedClass(Person.class);
			config.buildSessionFactory( serviceRegistry );
		} 
		catch( Exception e ) {
			StringWriter writer = new StringWriter();
			e.printStackTrace(new PrintWriter(writer));
            log.debug(writer.toString());
			fail(e.getMessage());
		} 
	} 
 
	public void testWithEJB3NamingStrategy() throws Exception {
6
CodeRank
This code example shows how to use the following methods:addAnnotatedClass, buildSessionFactory
		addAnnotationJars(jars);
 
		new ExecuteContext(getOutputDir(), file, jars) {
 
			protected void execute() throws Exception {
				AnnotationConfiguration configuration = new AnnotationConfiguration();
				configuration.addAnnotatedClass( getUcl().loadClass( "Project" ) );
				configuration.addAnnotatedClass( getUcl().loadClass( "Employee" ) );
			    configuration.addAnnotatedClass( getUcl().loadClass( "WorksOnContext" ) );
 
				SessionFactory sf = configuration.buildSessionFactory();
				Session s = sf.openSession();
				Query createQuery = s.createQuery("from java.lang.Object");
				createQuery.list();
				s.close();
				sf.close();
 
			} 
 
		}.run(); 
6
CodeRank
This code example shows how to use the following methods:addAnnotatedClass, configure
 
        if (sessionFactory == null) {
            try { 
                // Create the SessionFactory from standard (hibernate.cfg.xml) 
                // config file. 
                AnnotationConfiguration ac = new AnnotationConfiguration();
                ac.addAnnotatedClass(Livro.class);
                sessionFactory = ac.configure().buildSessionFactory();
                //SchemaExport se = new SchemaExport(ac); 
                //se.create(true, true); 
                 
 
            } catch (Throwable ex) {
                // Log the exception. 
                System.err.println("Initial SessionFactory creation failed." + ex);
                throw new ExceptionInInitializerError(ex);
            } 
 
            return sessionFactory;
 
6
CodeRank
This code example shows how to use the following methods:addAnnotatedClass, configure, buildSessionFactory
This code example shows how to use the following methods:addAnnotatedClass, setProperties
 
    protected Session session;
    protected Transaction transaction;
 
    private Configuration getConfiguration() {
        AnnotationConfiguration config = new AnnotationConfiguration();
 
        Properties properties = new Properties();
        properties.putAll(getDefaultProperties());
        properties.putAll(getConfigProperties());
 
        config.setProperties(properties);
        config.addAnnotatedClass(Contact.class);
 
 
        return config;
    } 
 
    private Properties getDefaultProperties() {
        Properties props = new Properties();
4
CodeRank
addAnnotatedClass Method Overview
Read metadata from the annotations associated with this class.
See Code Examples for other Hibernate ORM AnnotationConfiguration Methods: