congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
AnnotationSessionFactoryBean
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: stackoverflow.com

 @Bean
public AnnotationSessionFactoryBean sessionFactoryBean() {
  AnnotationSessionFactoryBean factory = new AnnotationSessionFactoryBean();
  // set up properties etc.
  return factory;
}

@Bean
public SessionFactory sessionFactory() {
  return (SessionFactory) sessionFactoryBean().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: 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: 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: stackoverflow.com

AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();  
sessionFactory.setDataSource(dataSource());
String[] pckage={"com.argus.intenew"};
sessionFactory.setPackagesToScan(pckage);  
sessionFactory.setHibernateProperties(hibProperties());
return sessionFactory; 
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;
 }
origin: stackoverflow.com

 @Bean
public SessionFactory sessionFactory() {
  AnnotationSessionFactoryBean sessionFactoryBean = 
       new AnnotationSessionFactoryBean();
  // ...configuration code here...
  sessionFactoryBean.afterPropertiesSet();
  return sessionFactoryBean.getObject();
}
origin: stackoverflow.com

 @Bean
  public AnnotationSessionFactoryBean sessionFactoryBean() {
...
    AnnotationSessionFactoryBean bean = new AnnotationSessionFactoryBean();
    bean.setAnnotatedClasses(new Class[]{Region.class});
...
    return bean;
  }
origin: stackoverflow.com

AnnotationSessionFactoryBean annotationSessionFactoryBean = new AnnotationSessionFactoryBean();
  annotationSessionFactoryBean.setPackagesToScan(new String[]{"com.sample"});
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

AnnotationSessionFactoryBean lsfb = new AnnotationSessionFactoryBean();
Class [] annotatedClasses =  {Student.class};
lsfb.setAnnotatedClasses(annotatedClasses);
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

 AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
//set annotated classes.
sessionFactoryBean.setAnnotatedClasses(new Class<?>[]{VO1.class,VO2.class});
Properties props = new Properties();
//put all your hibernate configurations here

props.setProperty("dataSource.show_sql", "true");
props.setProperty("dataSource.dialect", "org.hibernate.dialect.MySQL5Dialect");
....
sessionFactoryBean.setHibernateProperties(props);

//Create DataSource Dynamically
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(...);
dataSource.setUrl(...);
dataSource.setUsername(...);
dataSource.setPassword(...);

sessionFactoryBean.setDataSource(ds);

//tell sessionFactoryBean that you are ready.
sessionFactoryBean.afterPropertiesSet();
SessionFactory sessionFactory = sessionFactoryBean.getObject();

HibernateTemplate template = new HibernateTemplate();
template.setSessionFactory(sessionFactory);
origin: stackoverflow.com

AnnotationSessionFactoryBean lsfb = new AnnotationSessionFactoryBean();    
annotationSessionFactoryBean.setPackagesToScan(new String[]{"com.sample"});
origin: stackoverflow.com

LocalSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
origin: stackoverflow.com

AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
sessionFactory.setDataSource(restDataSource());
org.springframework.orm.hibernate3.annotationAnnotationSessionFactoryBean

Javadoc

Subclass of Spring's standard LocalSessionFactoryBean for Hibernate, supporting annotation metadata for mappings.

Example for an AnnotationSessionFactoryBean bean definition:

 
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
<property name="dataSource" ref="dataSource"/> 
<property name="annotatedClasses"> 
<list> 
<value>test.package.Foo</value> 
<value>test.package.Bar</value> 
</list> 
</property> 
</bean>
Or when using classpath scanning for autodetection of entity classes:
 
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
<property name="dataSource" ref="dataSource"/> 
<property name="packagesToScan" value="test.package"/> 
</bean>

Requires Hibernate 3.6.x, as of Spring 4.0.

Most used methods

  • <init>
  • setDataSource
  • 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
  • scanPackages,
  • setConfigLocation

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • 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