JpaPersistenceConfig
@Configuration @EnableJpaRepositories(basePackageClasses = JpaPersistenceConfig.class) @EntityScan(basePackageClasses = JpaPersistenceConfig.class) @EnableTransactionManagement public class JpaPersistenceConfig
io/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:60–87JPA 持久化配置,保存相关配置项。位于 io.agentscope.builder.web.persistence.jpa 包。核心成员包括 transactionTemplate、jpaUserStore、jpaUserAgentDefinitionStore。
Wires the JPA-backed UserStore and UserAgentDefinitionStore. This is the only
persistence backend the builder ships with.
Default DataSource
The default application.yml points spring.datasource.url at an embedded H2
file under ${user.home}/.agentscope-builder/db — kept deliberately separate from
builder.workspace so workspace volumes never include the catalog tables. No external
services or extra setup are required for a single-node deployment.
Switching to MySQL / PostgreSQL
Activate the bundled jdbc Spring profile to flip the DataSource defaults to
MySQL-shaped values:
`--spring.profiles.active=jdbc
# Or override individual settings without the profile:
BUILDER_DB_URL=jdbc:postgresql://host:5432/agentscope_builder
BUILDER_DB_DRIVER=org.postgresql.Driver
BUILDER_DB_USER=...
BUILDER_DB_PASSWORD=...
BUILDER_JPA_DDL_AUTO=validate # once Flyway / Liquibase manage the schema
`
The MySQL (com.mysql:mysql-connector-j) and PostgreSQL (org.postgresql:postgresql)
JDBC drivers are bundled at runtime scope; the active Hibernate dialect is resolved from the
spring.datasource.url.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public org.springframework.transaction.support.TransactionTemplate transactionTemplate(org.springframework.transaction.PlatformTransactionManager txManager) | 设置事务模板。 Performs the transaction template operation. |
public UserStore jpaUserStore(UserEntityRepository repository, boolean seedUsers) | 执行JPA 用户存储相关操作。 Performs the jpa user store operation. |
public UserAgentDefinitionStore jpaUserAgentDefinitionStore(AgentEntityRepository repository) | 设置JPA 用户智能体定义存储。 Performs the jpa user agent definition store operation. |
方法详情Method Detail
transactionTemplate
public org.springframework.transaction.support.TransactionTemplate transactionTemplate(org.springframework.transaction.PlatformTransactionManager txManager)
设置事务模板。
Performs the transaction template operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
txManager | org.springframework.transaction.PlatformTransactionManager | tx 管理器(类型 `org.springframework.transaction.PlatformTransactionManager`)。The tx manager. |
org.springframework.transaction.support.TransactionTemplateio/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:68–72jpaUserStore
public UserStore jpaUserStore(UserEntityRepository repository, boolean seedUsers)
执行JPA 用户存储相关操作。
Performs the jpa user store operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repository | UserEntityRepository | 仓库(类型 `UserEntityRepository`)。The repository. |
seedUsers | boolean | 预置用户(类型 `boolean`)。The seed users. |
UserStoreio/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:74–80jpaUserAgentDefinitionStore
public UserAgentDefinitionStore jpaUserAgentDefinitionStore(AgentEntityRepository repository)
设置JPA 用户智能体定义存储。
Performs the jpa user agent definition store operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
repository | AgentEntityRepository | 仓库(类型 `AgentEntityRepository`)。The repository. |
UserAgentDefinitionStoreio/agentscope/builder/web/persistence/jpa/JpaPersistenceConfig.java:82–86