AnnotationConfiguration setProperty - 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 setProperty method.

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:setProperty, buildSessionFactory
	private static AnnotationConfiguration cfg;
 
    @BeforeClass 
    public static void prepare() { 
        cfg = new AnnotationConfiguration().configure();
        cfg.setProperty("hibernate.connection.url", "jdbc:hsqldb:hsql://localhost:9005/calopsita");
        sessionFactory = cfg.buildSessionFactory();
    } 
 
    @AfterClass 
    public static void destroy() { 
    	sessionFactory.close();
    } 
 
    @Before 
    public void setUp() { 
        factory = new HtmlUnitFactory();
        Browser browser = factory.getBrowser();
        session = sessionFactory.openSession();
        given = new GivenContexts(browser, session);
5
CodeRank
setProperty Method Overview
Set a property value by name
See Code Examples for other Hibernate ORM AnnotationConfiguration Methods: