如何使表只讀?

[英]How to make table read only?


I have two tables in db with bi-directional many-to-one association. The problem is that I want write datas only in one table. Second must be read only. I searched but didn't find any solutions. I use spring data, jpa, eclipselink, mysql. Maybe someone knows how to solve this issue? Thanks

我在db中有兩個表,具有雙向多對一關聯。問題是我只想在一個表中寫入數據。第二個必須是只讀的。我搜索但沒有找到任何解決方案。我使用spring數據,jpa,eclipselink,mysql。也許有人知道如何解決這個問題?謝謝

2 个解决方案

#1


0  

To limit permissions on a table you need to use REVOKE:

要限制表的權限,您需要使用REVOKE:

The REVOKE statement enables system administrators to revoke privileges from MySQL accounts. Each account name uses the format described in Section 6.2.3, “Specifying Account Names”.

REVOKE語句使系統管理員可以撤消MySQL帳戶的權限。每個帳戶名稱使用第6.2.3節“指定帳戶名稱”中所述的格式。

#2


0  

Thanks for help. I solved it programmatically. In my entity class for read-only table I inserted @ReadOnly annotation and :

感謝幫助。我以編程方式解決了它。在我的只讀表實體類中,我插入了@ReadOnly注釋,並且:

@OneToMany(targetEntity=Catalog.class, mappedBy="category", cascade={CascadeType.ALL},   fetch = FetchType.EAGER)
private List<Catalog> catalog;

and in target entity:

在目標實體中:

@ManyToOne()
@JoinColumn(name="cname", referencedColumnName="name")
private Category category;

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/08/17/712b24373d694cede3a6446b29291ca6.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com