Java Code Examples for com.jfinal.plugin.activerecord.ActiveRecordPlugin#addMapping()
The following examples show how to use
com.jfinal.plugin.activerecord.ActiveRecordPlugin#addMapping() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppConfig.java From jfinal-api-scaffold with MIT License | 6 votes |
/** * 插件配置 */ @Override public void configPlugin(Plugins me) { // C3p0Plugin cp = new C3p0Plugin(loadPropertyFile("jdbc.properties")); // me.add(cp); //初始化连接池插件 loadPropertyFile("jdbc.properties"); HikariCPPlugin hcp = new HikariCPPlugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password"), getProperty("driverClass"), getPropertyToInt("maxPoolSize")); me.add(hcp); ActiveRecordPlugin arp = new ActiveRecordPlugin(hcp); me.add(arp); arp.addMapping("t_user", User.USER_ID, User.class);//用户表 arp.addMapping("t_register_code", RegisterCode.MOBILE, RegisterCode.class); //注册验证码对象 arp.addMapping("t_feedback", FeedBack.class); //意见反馈表 }
Example 2
Source File: _MappingKit.java From sdb-mall with Apache License 2.0 | 5 votes |
public static void mapping(ActiveRecordPlugin arp) { arp.addMapping("area", "id", Area.class); arp.addMapping("campaign", "id", Campaign.class); arp.addMapping("cart", "id", Cart.class); arp.addMapping("delivery_corp", "code", DeliveryCorp.class); // Composite Primary Key order: favorite_goods,favorite_user arp.addMapping("favorite_goods", "favorite_goods,favorite_user", FavoriteGoods.class); arp.addMapping("goods", "sn", Goods.class); arp.addMapping("groupon", "id", Groupon.class); // Composite Primary Key order: groupon_id,user_id arp.addMapping("groupon_team", "groupon_id,user_id", GrouponTeam.class); arp.addMapping("logistics", "tracking_no", Logistics.class); arp.addMapping("order_detail", "detail_id", OrderDetail.class); arp.addMapping("order_master", "order_id", OrderMaster.class); arp.addMapping("product", "sn", Product.class); arp.addMapping("product_category", "id", ProductCategory.class); arp.addMapping("receiver", "id", Receiver.class); arp.addMapping("schedule_job", "job_id", ScheduleJob.class); arp.addMapping("schedule_job_log", "log_id", ScheduleJobLog.class); arp.addMapping("sn", "type", Sn.class); arp.addMapping("specification", "id", Specification.class); arp.addMapping("sys_captcha", "uuid", SysCaptcha.class); arp.addMapping("sys_config", "id", SysConfig.class); arp.addMapping("sys_log", "id", SysLog.class); arp.addMapping("sys_menu", "menu_id", SysMenu.class); arp.addMapping("sys_oss", "id", SysOss.class); arp.addMapping("sys_role", "role_id", SysRole.class); arp.addMapping("sys_role_menu", "id", SysRoleMenu.class); arp.addMapping("sys_user", "user_id", SysUser.class); arp.addMapping("sys_user_role", "id", SysUserRole.class); arp.addMapping("sys_user_token", "user_id", SysUserToken.class); arp.addMapping("user", "user_id", User.class); }
Example 3
Source File: _MappingKit.java From NewsRecommendSystem with MIT License | 5 votes |
public static void mapping(ActiveRecordPlugin arp) { arp.addMapping("news", "id", News.class); arp.addMapping("newslogs", "id", Newslogs.class); arp.addMapping("newsmodules", "id", Newsmodules.class); arp.addMapping("recommendations", "id", Recommendations.class); arp.addMapping("users", "id", Users.class); }
Example 4
Source File: DBKit.java From NewsRecommendSystem with MIT License | 5 votes |
public static void initalize() { try { HashMap<String, String> info = getDBInfo(); cp = new C3p0Plugin(info.get("url"), info.get("user"), info.get("password")); ActiveRecordPlugin arp = new ActiveRecordPlugin(cp); arp.addMapping("users", Users.class); arp.addMapping("news", News.class); arp.addMapping("newsmodules", Newsmodules.class); arp.addMapping("newslogs", Newslogs.class); arp.addMapping("recommendations", Recommendations.class); if(cp.start() && arp.start()) logger.info("数据库连接池插件启动成功......"); else logger.info("c3p0插件启动失败!"); logger.info("数据库初始化工作完毕!"); } catch (Exception e) { logger.error("数据库连接初始化错误!"); } return; }
Example 5
Source File: ExampleModelMapping.java From my_curd with Apache License 2.0 | 5 votes |
public static void mapping(ActiveRecordPlugin arp) { // 例子 单表结构 arp.addMapping("ex_single_table", "id", ExSingleTable.class); // 员工教育经历 arp.addMapping("ex_staff_education", "id", ExStaffEducation.class); // 员工工作经历 arp.addMapping("ex_staff_experience", "id", ExStaffExperience.class); // 员工家人 arp.addMapping("ex_staff_family", "id", ExStaffFamily.class); // 一线员工 arp.addMapping("ex_staff", "id", ExStaff.class); }
Example 6
Source File: SystemModelMapping.java From my_curd with Apache License 2.0 | 5 votes |
public static void mapping(ActiveRecordPlugin arp) { // 系统用户表 arp.addMapping("sys_user", "id", SysUser.class); // 角色 arp.addMapping("sys_role", "id", SysRole.class); // 系统菜单 arp.addMapping("sys_menu", "id", SysMenu.class); // 用户角色中间表 arp.addMapping("sys_user_role", "sysUserId,sysRoleId", SysUserRole.class); // 角色菜单中间表 arp.addMapping("sys_role_menu", "sysRoleId,sysMenuId", SysRoleMenu.class); // 菜单按钮 arp.addMapping("sys_button", "id", SysButton.class); // 角色 菜单按钮中间表 arp.addMapping("sys_role_button", "sysRoleId,sysButtonId", SysRoleButton.class); // 组织机构表 arp.addMapping("sys_org", "id", SysOrg.class); // 字典表 arp.addMapping("sys_dict", "id", SysDict.class); // 字典分组表 arp.addMapping("sys_dict_group", "id", SysDictGroup.class); // 通知消息 arp.addMapping("sys_notice", "id", SysNotice.class); // 通知消息从表 arp.addMapping("sys_notice_detail", "id", SysNoticeDetail.class); // 通知分类 arp.addMapping("sys_notice_type", "id", SysNoticeType.class); // 系统通知类型角色中间表 arp.addMapping("sys_notice_type_sys_role", "sysNoticeTypeId,sysRoleId", SysNoticeTypeSysRole.class); // 系统访问日志 arp.addMapping("sys_visit_log", "id", SysVisitLog.class); // 定时任务日志 arp.addMapping("sys_task_log", "id", SysTaskLog.class); // 系统设置项 arp.addMapping("sys_setting", "id", SysSetting.class); }
Example 7
Source File: AddonManager.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
private void startActiveRecordPlugin(AddonInfo addonInfo) { List<Class<? extends JbootModel>> modelClasses = addonInfo.getModels(); if (modelClasses != null && !modelClasses.isEmpty()) { ActiveRecordPlugin arp = addonInfo.getOrCreateArp(); List<com.jfinal.plugin.activerecord.Table> tableList = getTableList(arp); for (Class<? extends JbootModel> c : modelClasses) { Table tableAnnotation = c.getAnnotation(Table.class); boolean needAddMapping = true; if (tableList != null && !tableList.isEmpty()) { for (com.jfinal.plugin.activerecord.Table t : tableList) { if (t.getName().equals(AnnotationUtil.get(tableAnnotation.tableName()))) { needAddMapping = false; break; } } } if (needAddMapping) { if (StrUtil.isNotBlank(tableAnnotation.primaryKey())) { arp.addMapping(AnnotationUtil.get(tableAnnotation.tableName()), AnnotationUtil.get(tableAnnotation.primaryKey()), (Class<? extends Model<?>>) c); } else { arp.addMapping(AnnotationUtil.get(tableAnnotation.tableName()), (Class<? extends Model<?>>) c); } } } addonInfo.setArp(arp); arp.start(); } }
Example 8
Source File: ZrLogConfig.java From zrlog with Apache License 2.0 | 5 votes |
/** * 配置JFinal提供过简易版本的ORM(其实这里是叫Active+Record)。 * * @param dataSourceProvider * @return */ private ActiveRecordPlugin getActiveRecordPlugin(IDataSourceProvider dataSourceProvider) { ActiveRecordPlugin arp = new ActiveRecordPlugin("c3p0Plugin" + new Random().nextInt(), dataSourceProvider); arp.addMapping(User.TABLE_NAME, "userId", User.class); arp.addMapping(Log.TABLE_NAME, "logId", Log.class); arp.addMapping(Type.TABLE_NAME, "typeId", Type.class); arp.addMapping(Link.TABLE_NAME, "linkId", Link.class); arp.addMapping(Comment.TABLE_NAME, "commentId", Comment.class); arp.addMapping(LogNav.TABLE_NAME, "navId", LogNav.class); arp.addMapping(WebSite.TABLE_NAME, "siteId", WebSite.class); arp.addMapping(Plugin.TABLE_NAME, "pluginId", Plugin.class); arp.addMapping(Tag.TABLE_NAME, "tagId", Tag.class); return arp; }
Example 9
Source File: _MappingKit.java From sqlhelper with GNU Lesser General Public License v3.0 | 4 votes |
public static void mapping(ActiveRecordPlugin arp) { arp.addMapping("blog", "id", Blog.class); }
Example 10
Source File: MYSQLTableMappingKit.java From jfinal-ext3 with Apache License 2.0 | 4 votes |
public static void mapping(ActiveRecordPlugin arp) { // Composite Primary Key order: id,name //arp.addMapping("hello", "id,name", Hello.class); // Composite Primary Key order: id,name arp.addMapping("user", "id,name", User.class); }
Example 11
Source File: _MappingKit.java From jfinal-ext3 with Apache License 2.0 | 4 votes |
public static void mapping(ActiveRecordPlugin arp) { arp.addMapping("zcq", "id", Zcq.class); arp.addMapping("zcq_copy_zz", "name", ZcqCopyZz.class); }
Example 12
Source File: OaModelMapping.java From my_curd with Apache License 2.0 | 4 votes |
public static void mapping(ActiveRecordPlugin arp) { // 业务表定义信息 arp.addMapping("business_form_info", "id", BusinessFormInfo.class); // 请假流程表单 arp.addMapping("form_leave", "id", FormLeave.class); }