ddl

Generate DDL for JPA 2.0 with EclipseLink

我的梦境 提交于 2019-12-01 15:08:54
I've created my model classes with JPA 2.0 annotations. At runtime, I will use EclipseLink 2.2.0, but I've been careful to use only pure JPA annotations in my model classes. Now, how do I generate the schema DDL for the database ? I want to use the EclipseLink API to generate the DDL from the classes, but not at runtime. Instead, I want a Java class to run on the command line and which outputs the DDL. What this guy did for Hibernate , I want for EclipseLink. I'd also settle for an Ant task or some plugin for Maven. Also, I chose to name my file jpa.xml instead of persistence.xml ; bonus

Generate DDL for JPA 2.0 with EclipseLink

荒凉一梦 提交于 2019-12-01 13:58:48
问题 I've created my model classes with JPA 2.0 annotations. At runtime, I will use EclipseLink 2.2.0, but I've been careful to use only pure JPA annotations in my model classes. Now, how do I generate the schema DDL for the database ? I want to use the EclipseLink API to generate the DDL from the classes, but not at runtime. Instead, I want a Java class to run on the command line and which outputs the DDL. What this guy did for Hibernate, I want for EclipseLink. I'd also settle for an Ant task or

How can I validate data before insert/update with SQL Server?

我怕爱的太早我们不能终老 提交于 2019-12-01 12:31:41
I have a table defined like this CREATE TABLE [dbo].[ObjectRelationClauses] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [RelationId] INT NOT NULL, [OperatorType] NVARCHAR(3) NOT NULL, [LocalPropertyId] INT NOT NULL, [ForeignPropertyId] INT NULL, [ForeignValue] VARCHAR(255) NULL, [ParentClauseId] INT NULL ) I need to be able to raise an error if the value of both ForeignPropertyId and ForeignValue columns both null , otherwise I want to perform the operation. Here is what I tried CREATE TRIGGER [dbo].[Trigger_ObjectRelationClauses] ON [dbo].[ObjectRelationClauses] FOR INSERT, UPDATE AS BEGIN SET

How can I validate data before insert/update with SQL Server?

China☆狼群 提交于 2019-12-01 09:45:13
问题 I have a table defined like this CREATE TABLE [dbo].[ObjectRelationClauses] ( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [RelationId] INT NOT NULL, [OperatorType] NVARCHAR(3) NOT NULL, [LocalPropertyId] INT NOT NULL, [ForeignPropertyId] INT NULL, [ForeignValue] VARCHAR(255) NULL, [ParentClauseId] INT NULL ) I need to be able to raise an error if the value of both ForeignPropertyId and ForeignValue columns both null , otherwise I want to perform the operation. Here is what I tried CREATE TRIGGER

SQL Server 创建触发器(trigger)

倖福魔咒の 提交于 2019-12-01 09:03:20
触发器简介: 触发器是一种特殊的存储过程,它的执行不是由程序调用,也不是手动执行,而是由事件来触发。触发器是当对某一个表进行操作。例如:update、insert、delete这些操作的时候,系统会自动调用执行该表上对应的触发器。 触发器分类: 1、DML( 数据操纵语言 Data Manipulation Language)触发器:是指触发器在数据库中发生 DML 事件时将启用。DML事件是指在表或视图中对数据进行的 insert、update、delete 操作的语句。 2、DDL(数据定义语言 Data Definition Language)触发器:是指当服务器或数据库中发生 DDL 事件时将启用。DDL事件是指在表或索引中的 create、alter、drop 操作语句。 3、登陆触发器:是指当用户登录 SQL SERVER 实例建立会话时触发。如果身份验证失败,登录触发器不会触发。 其中 DML 触发器比较常用,根据 DML 触发器触发的方式不同又分为以下两种情况: after 触发器(之后触发):其中 after 触发器要求只有执行 insert、update、delete 某一操作之后触发器才会被触发,且只能定义在表上。 instead of 触发器 (之前触发):instead of 触发器并不执行其定义的操作(insert、update、delete

ogg112101同构部署for_oracle11gr2

我怕爱的太早我们不能终老 提交于 2019-12-01 08:01:45
2.1创建ogg操作系统用户: useradd -u 1003 -g oinstall -G dba ogg passwd ogg --源端开启归档,若归档路径不设置则pump进程启动报错 su - oracle mkdir archivelog sqlplus / as sysdba alter system set log_archive_dest_1='location=/home/oracle/archivelog'; shutdown immediate; startup mount; alter database archivelog; alter database open; alter system switch logfile; / archive log list; exit 2.2修改ogg操作系统用户环境变量,并链接oracle用户环境变量,修改实例名为jvm vi /home/ogg/.bash_profile export ORACLE_SID=orcl export ORACLE_BASE=/home/oracle/app/oracle export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1 export OGG_HOME=/ogg export PATH=$ORACLE

Wrap an Oracle schema update in a transaction

◇◆丶佛笑我妖孽 提交于 2019-12-01 06:48:35
I've got a program that periodically updates its database schema. Sometimes, one of the DDL statements might fail and if it does, I want to roll back all the changes. I wrap the update in a transaction like so: BEGIN TRAN; CREATE TABLE A (PKey int NOT NULL IDENTITY, NewFieldKey int NULL, CONSTRAINT PK_A PRIMARY KEY (PKey)); CREATE INDEX A_2 ON A (NewFieldKey); CREATE TABLE B (PKey int NOT NULL IDENTITY, CONSTRAINT PK_B PRIMARY KEY (PKey)); ALTER TABLE A ADD CONSTRAINT FK_B_A FOREIGN KEY (NewFieldKey) REFERENCES B (PKey); COMMIT TRAN; As we're executing, if one of the statements fail, I do a

Fluent Nhibernate Schema Generation

情到浓时终转凉″ 提交于 2019-12-01 06:27:22
I have been playing about with FluentNhibernate as part of the S#arp Architecture. Below is an example mapping. public class EventBaseMap : ClassMap<EventBase> { public EventBaseMap() { WithTable("Event_Header"); //NotLazyLoaded(); Id(x => x.Id).WithUnsavedValue(-1).GeneratedBy.Native(); Map(x => x.Name).WithLengthOf(50).Not.Nullable(); Map(x => x.Description).WithLengthOf(255); Map(x => x.Rating); Map(x => x.Price); Map(x => x.PhoneNumber).WithLengthOf(20).Not.Nullable(); Map(x => x.EmailAddress); Map(x => x.Website); Map(x => x.State).Not.Nullable().CustomSqlTypeIs("INT"); Component(x => x

Fluent Nhibernate Schema Generation

霸气de小男生 提交于 2019-12-01 05:01:27
问题 I have been playing about with FluentNhibernate as part of the S#arp Architecture. Below is an example mapping. public class EventBaseMap : ClassMap<EventBase> { public EventBaseMap() { WithTable("Event_Header"); //NotLazyLoaded(); Id(x => x.Id).WithUnsavedValue(-1).GeneratedBy.Native(); Map(x => x.Name).WithLengthOf(50).Not.Nullable(); Map(x => x.Description).WithLengthOf(255); Map(x => x.Rating); Map(x => x.Price); Map(x => x.PhoneNumber).WithLengthOf(20).Not.Nullable(); Map(x => x

Wrap an Oracle schema update in a transaction

99封情书 提交于 2019-12-01 04:44:04
问题 I've got a program that periodically updates its database schema. Sometimes, one of the DDL statements might fail and if it does, I want to roll back all the changes. I wrap the update in a transaction like so: BEGIN TRAN; CREATE TABLE A (PKey int NOT NULL IDENTITY, NewFieldKey int NULL, CONSTRAINT PK_A PRIMARY KEY (PKey)); CREATE INDEX A_2 ON A (NewFieldKey); CREATE TABLE B (PKey int NOT NULL IDENTITY, CONSTRAINT PK_B PRIMARY KEY (PKey)); ALTER TABLE A ADD CONSTRAINT FK_B_A FOREIGN KEY