当前位置: 首页>>代码示例>>Java>>正文


Java UserDataSet类代码示例

本文整理汇总了Java中ru.otus.base.dataSets.UserDataSet的典型用法代码示例。如果您正苦于以下问题:Java UserDataSet类的具体用法?Java UserDataSet怎么用?Java UserDataSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserDataSet类属于ru.otus.base.dataSets包,在下文中一共展示了UserDataSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public static void main(String[] args) {
    DBService dbService = new DBServiceImpl();

    String status = dbService.getLocalStatus();
    System.out.println("Status: " + status);

    dbService.save(new UserDataSet("tully", new PhoneDataSet("12345")));
    dbService.save(new UserDataSet("sully", new PhoneDataSet("67890")));

    UserDataSet dataSet = dbService.read(1);
    System.out.println(dataSet);

    dataSet = dbService.readByName("sully");
    System.out.println(dataSet);

    List<UserDataSet> dataSets = dbService.readAll();
    for (UserDataSet userDataSet : dataSets) {
        System.out.println(userDataSet);
    }

    dbService.shutdown();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:23,代码来源:Main.java

示例2: DBServiceImpl

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public DBServiceImpl() {
    Configuration configuration = new Configuration();

    configuration.addAnnotatedClass(UserDataSet.class);
    configuration.addAnnotatedClass(PhoneDataSet.class);
    configuration.addAnnotatedClass(EmptyDataSet.class);

    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    configuration.setProperty("hibernate.connection.driver_class", "com.mysql.cj.jdbc.Driver");
    configuration.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/db_example");
    configuration.setProperty("hibernate.connection.username", "tully");
    configuration.setProperty("hibernate.connection.password", "tully");
    configuration.setProperty("hibernate.show_sql", "true");
    configuration.setProperty("hibernate.hbm2ddl.auto", "create");
    configuration.setProperty("hibernate.connection.useSSL", "false");
    configuration.setProperty("hibernate.enable_lazy_load_no_trans", "true");

    sessionFactory = createSessionFactory(configuration);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:20,代码来源:DBServiceImpl.java

示例3: main

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public static void main(String[] args) {
    DBService dbService = new DBServiceImpl();

    String status = dbService.getLocalStatus();
    System.out.println("Status: " + status);

    dbService.save(new UserDataSet("tully"));
    dbService.save(new UserDataSet("sully"));

    UserDataSet dataSet = dbService.read(1);
    System.out.println(dataSet);

    dataSet = dbService.readByName("sully");
    System.out.println(dataSet);

    List<UserDataSet> dataSets = dbService.readAll();
    for (UserDataSet userDataSet : dataSets) {
        System.out.println(userDataSet);
    }

    dbService.shutdown();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:23,代码来源:Main.java

示例4: DBServiceImpl

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public DBServiceImpl() {
    Configuration configuration = new Configuration();

    configuration.addAnnotatedClass(UserDataSet.class);
    configuration.addAnnotatedClass(PhoneDataSet.class);

    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    configuration.setProperty("hibernate.connection.driver_class", "com.mysql.cj.jdbc.Driver");
    configuration.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/db_example");
    configuration.setProperty("hibernate.connection.username", "tully");
    configuration.setProperty("hibernate.connection.password", "tully");
    configuration.setProperty("hibernate.show_sql", "true");
    configuration.setProperty("hibernate.hbm2ddl.auto", "create");
    configuration.setProperty("hibernate.connection.useSSL", "false");
    configuration.setProperty("hibernate.enable_lazy_load_no_trans", "true");

    sessionFactory = createSessionFactory(configuration);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:19,代码来源:DBServiceImpl.java

示例5: DBServiceImpl

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public DBServiceImpl() {
    Configuration configuration = new Configuration();

    configuration.addAnnotatedClass(UserDataSet.class);
    configuration.addAnnotatedClass(PhoneDataSet.class);
    configuration.addAnnotatedClass(AddressDataSet.class);

    configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    configuration.setProperty("hibernate.connection.driver_class", "com.mysql.cj.jdbc.Driver");
    configuration.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/db_example");
    configuration.setProperty("hibernate.connection.username", "tully");
    configuration.setProperty("hibernate.connection.password", "tully");
    configuration.setProperty("hibernate.show_sql", "true");
    configuration.setProperty("hibernate.hbm2ddl.auto", "create");
    configuration.setProperty("hibernate.connection.useSSL", "false");
    configuration.setProperty("hibernate.enable_lazy_load_no_trans", "true");

    sessionFactory = createSessionFactory(configuration);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:20,代码来源:DBServiceImpl.java

示例6: main

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    DBService dbService = new DBServiceImpl();

    String status = dbService.getLocalStatus();
    System.out.println("Status: " + status);

    dbService.save(new UserDataSet("tully", new PhoneDataSet("12345")));
    dbService.save(new UserDataSet("sully", new PhoneDataSet("67890")));

    System.out.println(dbService.read(1));
    System.out.println(dbService.read(1));

    System.out.println(dbService.readByName("sully"));

    List<UserDataSet> dataSets = dbService.readAll();
    for (UserDataSet userDataSet : dataSets) {
        System.out.println(userDataSet);
    }

    hold();

    dbService.shutdown();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:24,代码来源:Main.java

示例7: readByName

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public UserDataSet readByName(String name) {
    CriteriaBuilder builder = session.getCriteriaBuilder();
    CriteriaQuery<UserDataSet> criteria = builder.createQuery(UserDataSet.class);
    Root<UserDataSet> from = criteria.from(UserDataSet.class);
    criteria.where(builder.equal(from.get("name"), name));
    Query<UserDataSet> query = session.createQuery(criteria);
    return query.uniqueResult();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:9,代码来源:UserDataSetDAO.java

示例8: DBServiceImpl

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public DBServiceImpl() {
    StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();

    Map<String, Object> settings = new HashMap<>();
    settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
    settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
    settings.put(Environment.URL, "jdbc:mysql://localhost:3306/db_example");
    settings.put(Environment.USER, "tully");
    settings.put(Environment.PASS, "tully");
    settings.put(Environment.HBM2DDL_AUTO, "create");
    settings.put(Environment.SHOW_SQL, true);
    settings.put(Environment.ENABLE_LAZY_LOAD_NO_TRANS, true);

    // c3p0 configuration
    settings.put(Environment.C3P0_MIN_SIZE, 5);         //Minimum size of pool
    settings.put(Environment.C3P0_MAX_SIZE, 20);        //Maximum size of pool
    settings.put(Environment.C3P0_ACQUIRE_INCREMENT, 1);//Number of connections acquired at a time when pool is exhausted
    settings.put(Environment.C3P0_TIMEOUT, 1800);       //Connection idle time

    registryBuilder.applySettings(settings);

    ServiceRegistry registry = registryBuilder.build();
    MetadataSources sources = new MetadataSources(registry)
            .addAnnotatedClass(PhoneDataSet.class)
            .addAnnotatedClass(UserDataSet.class)
            .addAnnotatedClass(AddressDataSet.class);


    Metadata metadata = sources.getMetadataBuilder().build();
    sessionFactory = metadata.getSessionFactoryBuilder().build();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:32,代码来源:DBServiceImpl.java

示例9: DBServiceImpl

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public DBServiceImpl() {
    StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();

    Map<String, Object> settings = new HashMap<>();
    settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
    settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
    settings.put(Environment.URL, "jdbc:mysql://localhost:3306/db_example");
    settings.put(Environment.USER, "tully");
    settings.put(Environment.PASS, "tully");
    settings.put(Environment.HBM2DDL_AUTO, "create");
    settings.put(Environment.SHOW_SQL, true);
    settings.put(Environment.ENABLE_LAZY_LOAD_NO_TRANS, true);

    // c3p0 configuration
    settings.put(Environment.C3P0_MIN_SIZE, 5);         //Minimum size of pool
    settings.put(Environment.C3P0_MAX_SIZE, 20);        //Maximum size of pool
    settings.put(Environment.C3P0_ACQUIRE_INCREMENT, 1);//Number of connections acquired at a time when pool is exhausted
    settings.put(Environment.C3P0_TIMEOUT, 1800);       //Connection idle time

    registryBuilder.applySettings(settings);

    ServiceRegistry registry = registryBuilder.build();
    MetadataSources sources = new MetadataSources(registry)
            .addAnnotatedClass(PhoneDataSet.class)
            .addAnnotatedClass(UserDataSet.class);


    Metadata metadata = sources.getMetadataBuilder().build();
    sessionFactory = metadata.getSessionFactoryBuilder().build();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:31,代码来源:DBServiceImpl.java

示例10: save

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public void save(UserDataSet dataSet) {
    session.save(dataSet);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:4,代码来源:UserDataSetDAO.java

示例11: read

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public UserDataSet read(long id) {
    return session.load(UserDataSet.class, id);
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:4,代码来源:UserDataSetDAO.java

示例12: readAll

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public List<UserDataSet> readAll() {
    CriteriaBuilder builder = session.getCriteriaBuilder();
    CriteriaQuery<UserDataSet> criteria = builder.createQuery(UserDataSet.class);
    criteria.from(UserDataSet.class);
    return session.createQuery(criteria).list();
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:7,代码来源:UserDataSetDAO.java

示例13: save

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public void save(UserDataSet dataSet) {
    try (Session session = sessionFactory.openSession()) {
        UserDataSetDAO dao = new UserDataSetDAO(session);
        dao.save(dataSet);
    }
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:7,代码来源:DBServiceImpl.java

示例14: readByName

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public UserDataSet readByName(String name) {
    return runInSession(session -> {
        UserDataSetDAO dao = new UserDataSetDAO(session);
        return dao.readByName(name);
    });
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:7,代码来源:DBServiceImpl.java

示例15: readAll

import ru.otus.base.dataSets.UserDataSet; //导入依赖的package包/类
public List<UserDataSet> readAll() {
    return runInSession(session -> {
        UserDataSetDAO dao = new UserDataSetDAO(session);
        return dao.readAll();
    });
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_04,代码行数:7,代码来源:DBServiceImpl.java


注:本文中的ru.otus.base.dataSets.UserDataSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。