小编Vol*_*kyi的帖子

@CreatedBy如何在Spring Data JPA中运行?

@CreatedDate在实体属性上使用,我看到它在db中插入日期.我不明白@CreatedBySpring Data JPA 中注释的目的是什么.

参考文档中,我读到:

我们提供@CreatedBy,@LastModifiedBy捕捉谁创建或修改该实体的用户

但是如何创建和使用这样的用户呢?

java spring jpa spring-data spring-data-jpa

10
推荐指数
2
解决办法
1万
查看次数

如何在junit @BeforeClass静态方法中访问spring ApplicationContext?

我试图通过以下方式获得它:

private static ApplicationContext applicationContext;
@Autowired
    public static void setApplicationContext(ApplicationContext applicationContext) {
        AuditorTest.applicationContext = applicationContext;
    }
Run Code Online (Sandbox Code Playgroud)

但这并不能像其他所有尝试一样起作用。

如何自动连接静电ApplicationContext

java spring

5
推荐指数
1
解决办法
2896
查看次数

使用hibernate.hbm2ddl.import_files执行sql脚本时出错?

我使用h2 db和hibernate 4.

我想从实体自动生成db模式并从import.sql文件填充db .这是相关的hibernate.cfg.xml:

<!-- automatically generate database tables from hibernate entities -->
        <property name="hibernate.hbm2ddl.auto">create-drop</property>
        <!-- initialize db on startup -->
        <property name="hibernate.hbm2ddl.import_files">/import.sql</property>
Run Code Online (Sandbox Code Playgroud)

因此,在生成数据库表时会import.sql调用它.这是第一个sql语句:

insert into Borrower values (1,"Greece, Aphines, Square street",5,"Antonio");
Run Code Online (Sandbox Code Playgroud)

当hibernate运行这个sql语句时,它会给出一个错误:

    ???? 23, 2015 8:56:43 PM org.hibernate.tool.hbm2ddl.SchemaExport importScript
    ERROR: HHH000388: Unsuccessful: insert into Borrower values (1,"Greece, Aphines, Square street",5,"Antonio")
    ???? 23, 2015 8:56:43 PM org.hibernate.tool.hbm2ddl.SchemaExport importScript
    Column "Greece, Aphines, Square street" not found; SQL statement:
insert into Borrower values (1,"Greece, Aphines, …
Run Code Online (Sandbox Code Playgroud)

java sql hibernate h2

1
推荐指数
1
解决办法
2002
查看次数

标签 统计

java ×3

spring ×2

h2 ×1

hibernate ×1

jpa ×1

spring-data ×1

spring-data-jpa ×1

sql ×1