Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何用SpringData JPA去连接table with dynamic name? #47

Open
bihjuchiu opened this issue Jun 15, 2017 · 3 comments
Open

如何用SpringData JPA去连接table with dynamic name? #47

bihjuchiu opened this issue Jun 15, 2017 · 3 comments

Comments

@bihjuchiu
Copy link

当define table 的时候, table name 是define在@table的name里, 如下例:

======================================================
@entity
@DaTa
@table(name = "category", indexes = {@Index(name = "index_category_name", columnList = "categoryName", unique = true)})
public class Category {
@id
@GeneratedValue
private long id;

======================================================
但是如果table name 是每日更新的话,比如:
name = category_mm_dd_yyyy
ex:
category_01_01_2017: category generated at 01/01/2017
category_01_02_2017: category generated at 01/02/2017
category_01_03_2017: category generated at 01/03/2017

有没有办法设计 Category object 去dynamically更新table name?

@icyhins
Copy link

icyhins commented Jun 16, 2017

这样设计感觉比较怪异,因为基本数据库结构是设计阶段就固定下来,除非因为业务的需要偶尔做扩展。
动态表结构,不如以表名作为key保存在Redis中,并在SQL DB,使用date字段来作为对应日期的搜索条件。

@bihjuchiu
Copy link
Author

嗯嗯,这是一种解决的办法。。。

@jygan
Copy link
Contributor

jygan commented Jun 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants