Tabnine Logo
AnnotationSessionFactoryBean.setDataSource
Code IndexAdd Tabnine to your IDE (free)

How to use
setDataSource
method
in
org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

Best Java code snippets using org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.setDataSource (Showing top 8 results out of 315)

origin: madvirus/spring4

@Bean
public LocalSessionFactoryBean sessionFactoryBean() {
  AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
  sessionFactoryBean.setDataSource(dataSource());
  sessionFactoryBean.setAnnotatedClasses(Item.class, PaymentInfo.class, PurchaseOrder.class);
  Properties prop = new Properties();
  prop.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
  sessionFactoryBean.setHibernateProperties(prop);
  return sessionFactoryBean;
}
origin: com.custardsource.dybdob/dybdob-core

public WarningRecordRepository(String jdbcDriver, String jdbcConnection, String jdbcUser, String jdbcPassword, String hibernateDialect) {
  try {
    Class.forName(jdbcDriver);
  } catch (ClassNotFoundException e) {
    throw new RuntimeException("Cannot load specified JDBC driver: " + jdbcDriver, e);
  }
  DriverManagerDataSource dataSource=new DriverManagerDataSource(jdbcConnection, jdbcUser, jdbcPassword);
  AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
  sessionFactoryBean.setDataSource(dataSource);
  Properties config = new Properties();
  config.setProperty("hibernate.dialect", hibernateDialect);
  config.setProperty("hibernate.connection.autocommit", "true");
  config.setProperty("hibernate.hbm2ddl.auto", "update");
  sessionFactoryBean.setHibernateProperties(config);
  sessionFactoryBean.setAnnotatedClasses(new Class<?>[]{WarningRecord.class});
  try {
    sessionFactoryBean.afterPropertiesSet();
  } catch (Exception e) {
    throw new RuntimeException("Could not set up database connection", e);
  }
  hibernateTemplate = new HibernateTemplate((SessionFactory) sessionFactoryBean.getObject());
}
origin: stackoverflow.com

 AnnotationSessionFactoryBean sfb = new AnnotationSessionFactoryBean();
sfb.setDataSource( ds );
sfb.setHibernateProperties( hibProps);
sfb.setPackagesToScan( ... );
sfb.initialise();
SessionFactory sf = sfb.getObject();
origin: spring-projects/spring-framework-issues

@Bean
public SessionFactory sessionFactory() throws Exception
{
  AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
  bean.setDataSource(dataSource());
  bean.setPackagesToScan(new String[] {"org.springframework.issues"});
  bean.setHibernateProperties(hibernateProps());
  bean.afterPropertiesSet();
  return bean.getObject();
}
origin: spring-projects/spring-framework-issues

@Bean
public SessionFactory sessionFactory() throws Exception
{
  AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
  bean.setDataSource(dataSource());
  bean.setPackagesToScan(new String[] {"org.springframework.issues"});
  bean.setHibernateProperties(hibernateProps());
  bean.afterPropertiesSet();
  return bean.getObject();
}
origin: stackoverflow.com

 @Configuration
//@ComponentScan(basePackages = "de.webapp.daocustomer", excludeFilters = {@ComponentScan.Filter(Configuration.class), @ComponentScan.Filter(Controller.class)})
@ImportResource({"classpath*:componentScan.xml","classpath*:properties-config.xml","classpath*:security-context.xml"})
public class AppConfig
{
...
@Bean
public SessionFactory sessionFactory() throws Exception
{
  AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
  bean.setDataSource(dataSource());
  bean.setPackagesToScan(new String[] {"de.webapp"});
  bean.setHibernateProperties(hibernateProps());
  bean.afterPropertiesSet();
  return bean.getObject();
}
origin: stackoverflow.com

public AnnotationSessionFactoryBean sessionFactory() { 
  AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();  
  sessionFactory.setDataSource(dataSource());
  String[] pckage={"com.argus.intenew"};
  sessionFactory.setPackagesToScan(pckage);  
origin: stackoverflow.com

 @Bean
public BasicDataSource dataSource(){
    BasicDataSource basicDataSource=new BasicDataSource();
    basicDataSource.addConnectionProperty("destroy-method","close");
    basicDataSource.setDriverClassName("com.mysql.jdbc.Driver");
    basicDataSource.setUsername("root");
    basicDataSource.setUrl("jdbc:mysql://localhost/dbname");
    basicDataSource.setPassword("");
    return basicDataSource;
}

@Bean
public AnnotationSessionFactoryBean sessionFactoryBean(){
    AnnotationSessionFactoryBean asfb=new AnnotationSessionFactoryBean();
    asfb.setDataSource(dataSource());
    asfb.setConfigLocation(new ClassPathResource("hibernate.cfg.xml"));
    asfb.setHibernateProperties(hibernateProperties());

    return asfb;
}
public SessionFactory sessionFactory(){
   return sessionFactoryBean().getObject();
}
private Properties hibernateProperties(){
    Properties properties=new Properties();
    properties.put("dialect","org.hibernate.dialect.MySQLDialect");

    return properties;
 }
org.springframework.orm.hibernate3.annotationAnnotationSessionFactoryBeansetDataSource

Popular methods of AnnotationSessionFactoryBean

  • <init>
  • setHibernateProperties
  • afterPropertiesSet
  • getObject
  • setAnnotatedClasses
  • setPackagesToScan
    Specify packages to search using Spring-based scanning for entity classes in the classpath. This is
  • getHibernateProperties
  • initialise
  • matchesEntityTypeFilter
    Check whether any of the configured entity type filters matches the current class descriptor contain
  • scanPackages
    Perform Spring-based scanning for entity classes.
  • setConfigLocation
  • setConfigLocation

Popular in Java

  • Parsing JSON documents to java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • String (java.lang)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now