Populating Data Model

本文详细介绍了如何通过hMC手动创建和管理数据,以及如何利用ImpEx文件批量导入数据。包括创建和编辑实体,如体育场,以及如何将匹配数据分配给这些实体。此外,解释了在初始化和更新过程中平台如何查找并导入ImpEx文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

方法1、Enter data via the hMC

First we will create data manually in the hMC:

  1. Start hybris and navigate to the hmc http://localhost:9001/hmc/hybris
  2. Browse to Stadium, click New and enter the data below. Click Create to save the new Stadium
  3. Add a second stadium Allianz with Capacity 66000

Add some matches to the Stadium created above. 

  1. Make sure you have entered the Cuppy, CuppyTrail and CuppyTrailhmc extensions in your localextensions.xml file. You can check that they've been included in the build by looking at the platform - extensions page in the hAC.
  2. Assign some matches to the newly created stadiums
  • Right-click on the matches field to get a context menu - select + Add Match
  • In the new search window, click on the search button
  • In the results area, select some matches by clicking anywhere in the match row except the little blue button
  • Then click the use button
  • This will return the selected matches to the stadium

In this use case we have added Matches to the Stadium which illustrates how the hMC handles relationships defined in the items.xml file.


方法2、ImpEx by Convention

During the initialization and update processes, the platform looks for ImpEx files in the <extension_name> /resources/impex folder. In particular:

  • For essential data: The platform scans the <extension_name> /resources/impex  folders for files with names that match the pattern essentialdata*.impex and imports the files during the essential data creation.

  • For project data: The platform scans the <extension_name> /resources/impex folders for files with names that match the pattern projectdata*.impex and imports the files during the project data creation.

The ImpEx directory does not exist by default. You must create it and copy files to it.

For example, if you have the following folder structure:

  • resources/impex/essentialdataOne.impex

  • resources/impex/essDataOne.impex

  • resources/impex/DataOne.csv

  • resources/impex/projectdataOne.impex

The files essentialdataOne.impex and projectdataOne.impex are located and imported during the essential and project data imports respectively.

If you have special folder structures or want to use another folder in the resources, you must override the configuration in your local.properties file:

  • For essential data, add the property <extension_name>.essentialdata-impex-pattern .

  • For project data, use <extension_name>.projectdata-impex-pattern .

For example, assume that you have the following folder structure:

  • resources/test1.csv

  • resources/subfolder/test2.csv

  • resources/impex/subfolder/subfolder/test3.csv

In this structure, only the test1.csv  file has the pattern <extension_name>.essentialdata-impex-pattern=*.csv. In contrast to the example above, the pattern:extension_name .essentialdata-impex-pattern=*/.csv includes test1.csvtest2.csv and test3.csv.

If you want your configuration to work as the default does, you must set the pattern to < extension_name>   .essentialdata-impex-pattern=impex/essentialdata*.impex .
### 如何设置数据库模式并填充表格中的数据 为了帮助理解如何创建数据库模式并向表中插入数据,以下是基于提供的引用和其他专业知识的内容。 #### 创建数据库模式 在关系型数据库管理系统(RDBMS)中,创建数据库模式通常涉及定义表结构及其之间的关系。以下是一个简单的例子: ```sql CREATE TABLE Users ( UserID INT PRIMARY KEY, UserName VARCHAR(50), Email VARCHAR(100) ); CREATE TABLE Orders ( OrderID INT PRIMARY KEY, UserID INT, Amount DECIMAL(10, 2), FOREIGN KEY (UserID) REFERENCES Users(UserID) ); ``` 上述代码片段展示了两个表 `Users` 和 `Orders` 的创建过程[^1]。通过这种方式可以确保数据模型满足业务需求,并建立必要的约束条件来维护数据一致性。 如果使用的是 MongoDB 这样的 NoSQL 数据库,则可以通过编程语言实现类似的逻辑操作。例如,在 Java 中利用 Spring Data MongoDB 提供的功能快速完成初始化工作: ```java import org.springframework.data.mongodb.core.MongoTemplate; import com.mongodb.client.MongoClient; public class DatabaseSetup { public static void main(String[] args) { MongoClient mongoClient = ...; // Initialize client here. String dbName = "exampleDatabase"; MongoTemplate mongoTemplate = new MongoTemplate(mongoClient, dbName); // Example document insertion logic goes below this point... } } ``` 此段程序演示了怎样借助于 Spring Framework 下的工具类 `MongoTemplate` 来连接指定名称的数据存储实例[^2]。 #### 填充测试数据到已存在的表里去 当确认好架构之后就需要考虑怎么把实际的信息填进去。对于传统的关系型数据库而言,这一步骤可能涉及到执行批量 INSERT INTO 查询语句或者导入 CSV 文件等形式;而对于文档导向型非关系型数据库来说则可能是序列化对象再保存的过程。 假设我们已经有了上面提到过的两张表 (`Users`, `Orders`) ,那么现在就可以尝试往里面加入几条记录作为样例展示用途: ```sql INSERT INTO Users VALUES (1,'John Doe','john@example.com'), (2,'Jane Smith','jane@example.org'); INSERT INTO Orders VALUES (101,1,99.99),(102,2,45.67); ``` 这些命令将会分别向各自的对应位置写入新成员以及关联订单详情。 另外值得注意的一点是在某些情况下还需要提交事务才能让更改永久生效。比如当你正在使用 Oracle 数据库并通过其命令行界面(SQL*Plus)来进行管理的时候就应当记得发出 COMMIT 指令: ```bash COMMIT; ``` 最后提醒一下开发者们务必仔细阅读官方发布的更新日志文件以便及时了解到最新的改动之处从而调整自己的项目配置使之兼容最新版本特性[^3]。 #### 使用高级框架简化流程 现代开发环境中往往倾向于采用更高效的解决方案减少重复劳动量提高生产力水平。RestKit 就是这样一个用于 iOS 平台上的开源库它能够自动处理来自远程服务器端口返回来的 JSON 格式的响应消息转换成本地 CoreData 实体模型而无需手动解析每一个字段逐一赋值给属性变量等等繁琐步骤[^4]. 虽然这里讨论的主题主要围绕着后端部分但是前端同样存在许多优秀的第三方插件可以帮助加速整个应用程序构建周期因此建议大家多加探索学习不同技术栈的知识体系综合运用起来解决问题更加高效便捷。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值