ROO: how to create composite primary key in Entity - oracle

What can I do if I need to create entity for
a table in production DB (Oracle 10g) with composite primary key.
For example:
[CODE]
CREATE TABLE TACCOUNT
(
BRANCHID NUMBER(3) NOT NULL,
ACC VARCHAR2(18 BYTE) NOT NULL,
DATE_OPEN DATE NOT NULL,
DATE_CLOSE DATE,
NOTE VARCHAR2(38 BYTE)
);
CREATE UNIQUE INDEX PK_TACCOUNT ON TACCOUNT
(BRANCHID, ACC);
I don't want to change the structure of this table.
Is it possible to create an "id" field using roo commands?
I use Spring Roo 1.0.2.RELEASE [rev 638]

Related

How can I mapping Tables embeded in spring boot jpa?

i have create two table in sql like this:
create table dbo.person(
id int not null identity(1,1),
code nvarchar(50),
name nvarchar(250),
PRIMARY KEY (Id)
)
create table dbo.employ(
personId int not null,
age smallint,
sex bit,
PRIMARY KEY (personId),
FOREIGN KEY (PersonId) REFERENCES Persons(Id)
)
how can i pmapping this tables in spring boot jpa?

Create two tables in same schema.sql H2

I'm using Spring boot, and I have to initiate two tables for testing. I'm using the schema.sql inside the resource folder. But when I'm trying to create two tables in the same script and run the app, it can't load the application context.
Here is my schema.sql which I have placed at resource folder:
CREATE TABLE JobStatus_FO
(
id int(11) NOT NULL AUTO_INCREMENT,
businessDate timestamp NOT NULL,
label varchar(50),
);
CREATE TABLE JobStatusDetails_FO
{
id int(11) NOT NULL,
name varchar(50),
};
Please find the correct scripts as
CREATE TABLE JobStatus_FO
(
id INT(11) NOT NULL AUTO_INCREMENT,
businessDate TIMESTAMP NOT NULL,
label VARCHAR(50),
KEY id(id)
);
CREATE TABLE JobStatusDetails_FO
(
id INT(11) NOT NULL,
NAME VARCHAR(50)
);
Your syntax is not correct of create table .
1) In your scripts you have used extra comma "," before closing parentheses
2) Auto increment column should be used as a key in table
3) Curly braces "{" is not used within create table.
Hope this will work in to your project.

Unusable partition Oracle / datastage

I am facing an issue with my datastage job. I have to fill a table ttperiodeas in Oracle from a .csv file. The SQL query in Oracle connector is shown in this screenshot:
Oracle connector
And here is the oracle script
CREATE TABLE TTPERIODEAS
(
CDPARTITION VARCHAR2(5 BYTE) NOT NULL ENABLE,
CDCOMPAGNIE NUMBER(4,0) NOT NULL ENABLE,
CDAPPLI NUMBER(4,0) NOT NULL ENABLE,
NUCONTRA CHAR(15 BYTE) NOT NULL ENABLE,
DTDEBAS NUMBER(8,0) NOT NULL ENABLE,
DTFINAS NUMBER(8,0) NOT NULL ENABLE,
TAUXAS NUMBER(8,5) NOT NULL ENABLE,
CONSTRAINT PK_TTPERIODEAS
PRIMARY KEY (CDPARTITION, CDCOMPAGNIE, CDAPPLI, NUCONTRA, DTDEBAS)
)
PARTITION BY LIST(CDPARTITION)
(PARTITION P_PERIODEAS_13Q VALUES ('13Q'));
When running the job, I get the following message error and the table is not filled.:
The index 'USINODSD0.SYS_C00249007' its partition is unusable
Please I need help thanks
The index is global (i.e. not partitioned) because there is no using index local at the end of the definition. This is also true for the PK index shown above. (I'm assuming they are two different things, because by default the DDL above would create an index named PK_TTPERIODEAS, so I'm not sure what SYS_C00249007 is.) If you can drop and rebuild them as local indexes (i.e. partitioned to match the table) then truncating or dropping a partition will no longer invalidate indexes.
For example, you could rebuild the primary key as:
alter table ttperiodeas
drop primary key;
alter table ttperiodeas
add constraint pk_ttperiodeas primary key (cdpartition,cdcompagnie,cdappli,nucontra,dtdebas)
using index local;
I don't know how SYS_C00249007 is defined, but you could use something similar.
The create table command might be something like:
create table ttperiodeas
( cdpartition varchar2(5 byte) not null
, cdcompagnie number(4,0) not null
, cdappli number(4,0) not null
, nucontra varchar2(15 byte) not null
, dtdebas number(8,0) not null
, dtfinas number(8,0) not null
, tauxas number(8,5) not null
, constraint pk_ttperiodeas
primary key (cdpartition,cdcompagnie,cdappli,nucontra,dtdebas)
using index local
)
partition by list(cdpartition)
( partition p_periodeas_13q values ('13Q') );
Alternatively, you could add the update global indexes clause when dropping the partition:
alter table demo_temp drop partition p_periodeas_14q update global indexes;
(By the way, NUCONTRA should probably be a standard VARCHAR2 and not CHAR, which is intended for cross-platform compatibility and ANSI completeness, and in practice just wastes space and creates bugs.)
the message says that the index for the given partition is unusable: so you could try to rebuild the correponding index partition by the use of
create index [index_name] rebuild partition [partition_name]
(with the fitting values for [index_name] and [partition_nme].
Before you do that you should check the status of the index partitions in user_indexes - since your error message looks not like Oracle error messages usually do.
But since the index is global as William Robertson pointed out, this is not applicable for the given situation.

Add multiple language record in oracle database

Hi I have created a table Continent using below query
CREATE TABLE CONTINENTS
(
CONTNTCOD NUMBER(2) NOT NULL,
LOOKUPCOD VARCHAR2(20),
CONTNAM VARCHAR2(50),
CONTNAM_LCLLANG VARCHAR2(50),
);
The fourth column i.e. CONTNAM_LCLLANG is used to store data in different language.
When i tried to insert
अभिषेक it inserted something ¿¿¿¿¿¿
Select Unicode like utf8 or utf8_general_ci( in mysql ) because it support a many characters.
so, what you can do is change varchar to nvarchar
CREATE TABLE CONTINENTS
(
CONTNTCOD NUMBER(2) NOT NULL,
LOOKUPCOD VARCHAR2(20),
CONTNAM VARCHAR2(50),
CONTNAM_LCLLANG NVARCHAR2(50),
);

CodeIgniter dependencies between models, without using any ORM or DataMapper systems

I'm writing a CRUD system using CodeIgniter, implementing some 'one to many' dependencies between models (without using any ORM or DataMapper systems) by calling methods from one model to another.
For example: in a "many Documents per User" realeation, when deleting a User, the User_Model directly calls the delete() method on the Document_Model, deleting any documents associated with it.
I’m certain there’s a better way implementing 'one to many' model releation (without ORM, etc.. ), and would appreciate some guidance.
Thanks
Alon.
Of course! You are allowed to use InnoDB engine. This engine has functionally foreign keys, so you can do smth like that, for example (very basic)
CREATE TABLE IF NOT EXISTS `documents` (
`did` bigint(11) NOT NULL AUTO_INCREMENT,
`uid` bigint(11) NOT NULL,
`data` varchar(255) NOT NULL,
PRIMARY KEY (`did`),
KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `user` (
`uid` bigint(11) NOT NULL AUTO_INCREMENT,
`name` varchar(25) NOT NULL,
`password` varchar(25) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
ALTER TABLE `documents`
ADD CONSTRAINT `documents_cstr_1` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE NO ACTION ON UPDATE CASCADE;

Resources