JPA註解:根據實體生成資料表和欄位的註釋(正向工程)
@org.hibernate.annotations.Table(appliesTo = "TableName",comment="表註釋")
3.JPA註解:欄位註釋
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
importstatic java.lang.annotation.ElementType.TYPE;
importstatic java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Complementary information to a table either primary or secondary.
*
* @author Emmanuel Bernard
*/
@Target({TYPE})
@Retention(RUNTIME)
public@interfaceTable{
/**
* name of the targeted table.
*/
String appliesTo();
/**
* Indexes.
*/
Index[] indexes()default{};
/**
* define a table comment.
*/
String comment()default"";
/**
* Defines the Foreign Key name of a secondary table pointing back to the primary table.
*/
ForeignKey foreignKey()default@ForeignKey( name="");
/**
* If set to JOIN, the default, Hibernate will use an inner join to retrieve a
* secondary table defined by a class or its superclasses and an outer join for a
* secondary table defined by a subclass.
* If set to select then Hibernate will use a
* sequential select for a secondary table defined on a subclass, which will be issued only if a row
* turns out to represent an instance of the subclass. Inner joins will still be used to retrieve a
* secondary defined by the class and its superclasses.
*
* <b>Only applies to secondary tables</b>
*/
FetchMode fetch()defaultFetchMode.JOIN;
/**
* If true, Hibernate will not try to insert or update the properties defined by this join.
*
* <b>Only applies to secondary tables</b>
*/
boolean inverse()defaultfalse;
/**
* If enabled, Hibernate will insert a row only if the properties defined by this join are non-null
* and will always use an outer join to retrieve the properties.
*
* <b>Only applies to secondary tables</b>
*/
boolean optional()defaulttrue;
/**
* Defines a custom SQL insert statement.
*
* <b>Only applies to secondary tables</b>
*/
SQLInsert sqlInsert()default@SQLInsert(sql="");
/**
* Defines a custom SQL update statement.
*
* <b>Only applies to secondary tables</b>
*/
SQLUpdate sqlUpdate()default@SQLUpdate(sql="");
/**
* Defines a custom SQL delete statement.
*
* <b>Only applies to secondary tables</b>
*/
SQLDelete sqlDelete()default@SQLDelete(sql="");
}
@Column(name="columnComment",columnDefinition="varchar(200) COMMENT '欄位註釋'")
/*
* Copyright (c) 2008, 2009, 2011 Oracle, Inc. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution. The Eclipse Public License is available
* at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License
* is available at http://www.eclipse.org/org/documents/edl-v10.php.
*/
package javax.persistence;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
importstatic java.lang.annotation.ElementType.FIELD;
importstatic java.lang.annotation.ElementType.METHOD;
importstatic java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Is used to specify the mapped column for a persistent property or field.
* If no <code>Column</code> annotation is specified, the default values apply.
*
* <blockquote><pre>
* Example 1:
*
* @Column(name="DESC", nullable=false, length=512)
* public String getDescription() { return description; }
*
* Example 2:
*
* @Column(name="DESC",
* columnDefinition="CLOB NOT NULL",
* table="EMP_DETAIL")
* @Lob
* public String getDescription() { return description; }
*
* Example 3:
*
* @Column(name="ORDER_COST", updatable=false, precision=12, scale=2)
* public BigDecimal getCost() { return cost; }
*
* </pre></blockquote>
*
*
* @since Java Persistence 1.0
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public@interfaceColumn{
/**
* (Optional) The name of the column. Defaults to
* the property or field name.
*/
String name()default"";
/**
* (Optional) Whether the column is a unique key. This is a
* shortcut for the <code>UniqueConstraint</code> annotation at the table
* level and is useful for when the unique key constraint
* corresponds to only a single column. This constraint applies
mysql中為使用者設定資料庫,資料表,欄位(列)的訪問許可權
1、mysql中對指定使用者,授予某些資料庫,資料表或者欄位訪問許可權 語法: GRANT PRIVILEGES ON DATA.TABLE TO USERS; 溫馨提示: 授權後可以使用2中命令進行使用者許可權許可權,也可以直接重啟mysql程序方式進行許可權重新整理。 A
MySQL(九)之資料表的查詢詳解(SELECT語法)二
上一篇講了比較簡單的單表查詢以及MySQL的組函式,這一篇給大家分享一點比較難得知識了,關於多表查詢,子查詢,左連線,外連線等等。希望大家能都得到幫助! 在開始之前因為要多表查詢,所以搭建好環境: 1)建立資料表suppliers 前面已經有一張表是book表,我們
MySQL中大資料表增加欄位,增加索引實現
最近遇到的一個問題,需要在一張1800萬資料量的表中新增加一個欄位並新增索引,但是直接新增會導致mysql崩潰或者鎖表時間太長影響使用者操作,所以需要利用其他的方法進行新增,這篇文章主要給大家介紹了MySQL中大資料表增加欄位,增加索引的實現過程,需要的朋友可以參考借鑑。
Oracle查詢資料表結構/欄位/型別/大小
Oracle資料庫字典在Oracle的絕大多數資料字典檢視中都有象DBA_TABLES,ALL_TABLES和USER_TABLES這樣的檢視家族。Oracle中有超過100個檢視家族,下表列出了最重要和最常用的檢視家族,需要注意的是每個檢視家族都有一個DBA_,一個ALL_
如果資料表或欄位名是SQL關鍵字怎麼辦
比如最常見的USER作為表名,用SQL語句“select * from USER”查詢就會出現如下錯誤:在關鍵字 'USER' 附近有語法錯誤 可以用[ ]避免出現這樣的錯誤,即:將SQL語句改正這樣“select * from [USER]”
獲取資料表的欄位名和欄位註釋
1、oracle: SELECT t1.COLUMN_NAME, t2.COMMENTS FROM user_tab_columns t1, user_col_comment
sql server2008給資料表,欄位,新增修改註釋
1、sqlserver用語句給表註釋 EXECUTE sp_addextendedproperty N'MS_Description', N'表註釋', N'user', N'dbo', N'table', N'表名', NULL, NULL 2、sqlserver用語句給表的“欄位”註釋 EXECUT
TP中可通過欄位對映隱藏資料表的欄位名
在ThinkPhP中,我們可以通過TP提供的一個關鍵字$_map來達到隱藏我們資料庫中表的欄位名的效果。 假設我們的User表裡面有username和email欄位,我們需要對映成另外的欄位,定義方式如下: 例子如下: namespace Home\Model;use Th
安卓註解使用,實體類指定須使用欄位, Google Gson 欄位過濾
實體類複用,專案中往往會遇到這樣一些問題,有一個欄位很多的實體類,然後向服務端提交資料的時候卻不需要這個實體類的全部欄位。所以我們通常的方法就是再新建一個只有需要欄位的實體類。還有一種方法就是本文要說到的註解,給某個操作時需要用到的欄位加上註解: 1.新介面Submi
在oracle中操作表及欄位註釋
1、查詢表註釋 SELECT * FROM USER_TAB_COMMENTS;三列:TABLE_NAME,TABLE_TYPE,COMMENTS 2、查詢欄位註釋 SELECT * FROM USER_COL_COMMENTS;三列:TABLE_NAME,COLUMN_NAME,COM
mysql 初體驗 -----(資料和欄位的增刪改查)
上篇隨筆說到了如何去安裝和 DOS命令 一些最簡單的操作,以及如何去鍵一個數據庫和如何建表。 這次接著來談mysql 裡資料和欄位的增刪改查 有增刪改查就會有資料型別以及資料型別的屬性 mysql資料型別和資料屬性有很多,先接觸一些最基本和最實用的的。 mysql 資料
fastadmin 的表註釋和欄位註釋
在安裝好 fastdamin 之後,看官方的文件,說是建立表的時候,要寫表註釋和欄位註釋; 不瞭解資料庫,只知道簡單的表和欄位的概念,這個註釋是什麼還真的不瞭解,於是,學習一下: 表註釋:在建立表的時候給表增加的說明文字; 看下fastadmin 的資料庫是怎麼樣的
檢視文章 mysql:表註釋和欄位註釋
1 建立表的時候寫註釋 create table test1 ( field_name int comment '欄位的註釋' )comment='表的註釋'; 2 修改表的註釋 alter table test1 comment '修改後的表的註釋'