Symfony-Bundle icon indicating copy to clipboard operation
Symfony-Bundle copied to clipboard

Problem with entities

Open UnknownNewUser opened this issue 5 years ago • 2 comments

Hi, I tried to integrate this bundle in a project which I am working on and everything is seems to be ok except when we try to interact with database,

The error messsage is:

An exception occurred while executing 'SELECT cron_job_id_seq.nextval FROM DUAL':                                                                   
ORA-02289: sequence does not exist                                                 
In OCI8Exception.php line 23:
                                      
ORA-02289: sequence does not exist  

And for info, the sequence cron_job_id_seq exist in database.

For info, we are using Oracle database and we use different schemas: Schema 1 which include tables and views Schema 2 which has some privileges on some tables and views in schema 1 And our application use schema 2 to connect to the database

The problem is already identified by us but we didn't find a solution to solve it without touching the entities in the bundle, The similar problem is explained in this link: https://stackoverflow.com/questions/25726573/sequence-doesnt-exist-ora-02289/25726744

The solution is to replace this line in the entity file: @ORM\GeneratedValue(strategy="AUTO") With:

@ORM\GeneratedValue(strategy="SEQUENCE")
@ORM\SequenceGenerator(sequenceName="schema 1.cron_job_id_seq", allocationSize=1, initialValue=1)

I also include some screenshots that might help to better understand the problem.

01 02

It will be nice if you will be able to provide a solution to solve this problem, Thank you in advance.

UnknownNewUser avatar Jan 06 '21 11:01 UnknownNewUser

Hi @UnknownNewUser, I've never validated if it works against Oracle, only MySQL was tested as far as I know. I'm not able to help with oracle related issues due to a lack of knowledge.

NoUseFreak avatar Jan 12 '21 16:01 NoUseFreak

Try to create those sequence in Oracle sql manager, maybe this helps you:

CREATE SEQUENCE cron_job_seq START WITH 1 INCREMENT BY 1;

CREATE OR REPLACE TRIGGER cron_job_seq_tr
 BEFORE INSERT ON cron_job FOR EACH ROW
 WHEN (NEW.id IS NULL)
BEGIN
 SELECT cron_job_seq.NEXTVAL INTO :NEW.id FROM DUAL
END

tocw86 avatar Sep 12 '22 10:09 tocw86

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 09 '23 02:11 github-actions[bot]