Package org.hibernate.ejb

Examples of org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate


       
    EntityManagerFactory factory = factories.get(key);
    if (factory != null)
      return factory;
   
    Ejb3Configuration cfg = new Ejb3Configuration();
    cfg.addAnnotatedClass(ch.hortis.sonar.model.ProjectSnapshot.class);
    cfg.addAnnotatedClass(ch.hortis.sonar.model.MavenProject.class);
    cfg.addAnnotatedClass(ch.hortis.sonar.model.Metric.class);
    cfg.addAnnotatedClass(ch.hortis.sonar.model.ProjectMetricMeasure.class);
    cfg.addAnnotatedClass(ch.hortis.sonar.model.SchemaInfo.class);
    cfg.addAnnotatedClass(ch.hortis.sonar.model.SnapshotGroup.class);
   
    Properties props = new Properties();
    if ( jdbcData.getDatasource() == null ) {
      props.put("hibernate.connection.url", jdbcData.getUrl());
      props.put("hibernate.connection.driver_class", jdbcData.getDriverClassName());
      props.put("hibernate.connection.username", jdbcData.getUsername());
      props.put("hibernate.connection.password", jdbcData.getPassword());
      props.put("hibernate.dialect", getHibernateDialect(jdbcData.getUrl()));
    } else {
      props.put("hibernate.connection.datasource", jdbcData.getDatasource());
      props.put("hibernate.dialect", getHibernateDialect(jdbcData.getDsDialect()));
    }

    props.put("hibernate.hbm2ddl.auto", "validate");
    props.put("hibernate.current_session_context_class", "thread");
    if (configuration != null) {
      props.putAll(configuration);
    }
    cfg.addProperties(props);
    factory = cfg.createEntityManagerFactory ();
     
    /*Map<String, String> settings = new HashMap<String, String>();
    settings.put("hibernate.connection.url", jdbcData.getUrl());
    settings.put("hibernate.connection.driver_class", jdbcData.getDriverClassName());
    settings.put("hibernate.connection.username", jdbcData.getUsername());
View Full Code Here


      }
    }

  @Override
  public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map) {
    Ejb3Configuration cfg = new Ejb3Configuration();
    if ( info.getTransactionType().equals( PersistenceUnitTransactionType.JTA ) ) {
      map.put( AvailableSettings.JTA_PLATFORM, new OsgiJtaPlatform( context ) );
    }
    Ejb3Configuration configured = cfg.configure( info, map );
    return configured != null ? configured.buildEntityManagerFactory() : null;
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info,
            Map map) {
        Ejb3Configuration cfg = new Ejb3Configuration();
        Ejb3Configuration configured = cfg.configure(info, map);
        postprocessConfiguration(info, map, configured);
        return configured != null ? configured.buildEntityManagerFactory() : null;
    }
View Full Code Here

    @Before
    public void beforeEach() throws Exception {
        model = new BasicModel();
        context = new ExecutionContext();
        // Connect to the database ...
        Ejb3Configuration configurator = new Ejb3Configuration();
        model.configure(configurator);
        configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
        configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
        configurator.setProperty("hibernate.connection.username", "sa");
        configurator.setProperty("hibernate.connection.password", "");
        configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
        configurator.setProperty("hibernate.show_sql", "false");
        configurator.setProperty("hibernate.format_sql", "true");
        configurator.setProperty("hibernate.use_sql_comments", "true");
        configurator.setProperty("hibernate.hbm2ddl.auto", "create");
        factory = configurator.buildEntityManagerFactory();
        manager = factory.createEntityManager();

        // Always create a bunch of nodes in a workspace that is not used, so we're sure that these
        // tests work only on the workspace used in the test
        NamespaceEntity ns = NamespaceEntity.findByUri(manager, "http://www.example.com");
View Full Code Here

    protected StoreOptions options;

    @BeforeClass
    public static void beforeAll() throws Exception {
        // Connect to the database ...
        Ejb3Configuration configurator = new Ejb3Configuration();
        configurator.addAnnotatedClass(StoreOptionEntity.class);
        configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
        configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
        configurator.setProperty("hibernate.connection.username", "sa");
        configurator.setProperty("hibernate.connection.password", "");
        configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
        configurator.setProperty("hibernate.show_sql", "false");
        configurator.setProperty("hibernate.format_sql", "true");
        configurator.setProperty("hibernate.use_sql_comments", "true");
        configurator.setProperty("hibernate.hbm2ddl.auto", "create");
        factory = configurator.buildEntityManagerFactory();
        manager = factory.createEntityManager();
    }
View Full Code Here

    }

    protected EntityManager startEntityManager() {
        if (manager == null) {
            // Connect to the database ...
            Ejb3Configuration configurator = new Ejb3Configuration();
            model.configure(configurator);
            configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
            configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
            configurator.setProperty("hibernate.connection.username", "sa");
            configurator.setProperty("hibernate.connection.password", "");
            configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
            configurator.setProperty("hibernate.show_sql", "false");
            configurator.setProperty("hibernate.format_sql", "true");
            configurator.setProperty("hibernate.use_sql_comments", "true");
            configurator.setProperty("hibernate.hbm2ddl.auto", "create");
            factory = configurator.buildEntityManagerFactory();
            manager = factory.createEntityManager();
        }
        return manager;
    }
View Full Code Here

        validLargeValues = new String[] {IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum1.txt")),
            IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum2.txt")),
            IoUtil.read(getClass().getClassLoader().getResourceAsStream("LoremIpsum3.txt"))};

        // Connect to the database ...
        Ejb3Configuration configurator = new Ejb3Configuration();
        model.configure(configurator);
        configurator.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
        configurator.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
        configurator.setProperty("hibernate.connection.username", "sa");
        configurator.setProperty("hibernate.connection.password", "");
        configurator.setProperty("hibernate.connection.url", "jdbc:hsqldb:.");
        configurator.setProperty("hibernate.show_sql", "false");
        configurator.setProperty("hibernate.format_sql", "true");
        configurator.setProperty("hibernate.use_sql_comments", "true");
        configurator.setProperty("hibernate.hbm2ddl.auto", "create");
        factory = configurator.buildEntityManagerFactory();
        manager = factory.createEntityManager();
        namespaces = new Namespaces(manager);

        uuidByPathByWorkspace = new HashMap<Long, Map<Path, UUID>>();
View Full Code Here

  }


  @Override
  protected void buildConfiguration() throws Exception {
    Ejb3Configuration ejbconfig = new Ejb3Configuration();
    TestCase.cfg = ejbconfig.getHibernateConfiguration();
    if ( recreateSchema() ) {
      cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    }
    //cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );

    for ( String mappingFile : getMappings() ) {
      cfg.addResource( mappingFile );
    }

    factory = ejbconfig.createEntityManagerFactory( getConfig() );
  }
View Full Code Here

  protected boolean recreateSchema() {
    return true;
  }

  private void buildConfiguration() {
    configuration = new Ejb3Configuration();
    configuration.addProperties( loadProperties() );
    if ( recreateSchema() ) {
      configuration.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    }
View Full Code Here

* @author Emmanuel Bernard
*/
public class ProgrammaticConfTest extends junit.framework.TestCase {

  public void testProgrammaticAPI() throws Exception {
    Ejb3Configuration conf = new Ejb3Configuration();
    conf.addAnnotatedClass( Cat.class );
    conf.addAnnotatedClass( Kitten.class );
    conf.addProperties(getProperties());
    EntityManagerFactory emf = conf.buildEntityManagerFactory();
    EntityManager em = emf.createEntityManager();
    Cat cat = new Cat();
    cat.setAge( 23 );
    cat.setDateOfBirth( new Date() );
    cat.setLength( 32 );
View Full Code Here

TOP

Related Classes of org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.