| Summary: | MaxDB: Duplicate schema name on sequence when table qualifier is set | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Sabine Heider <sabine.heider> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | konstantin.schwed, tom.ware | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 209535 [details]
Remove table qualifier from MaxDBPlatform.buildSelectQueryForSequenceObject
We would need the patch for 2.3 as well. The @Table annotation (and most other table related annotations)allows you to set schema (as does persistence-unit-defaults) in orm.xml. Do those allow you to get a test working? I can reproduce the error only with a session customizer. Neither setting a schema in <persistence-unit-defaults> nor in the @Table annotation produces the duplication, as both don't result in the tableQualifier being set on the DatabasePlatform (don't know whether that is another bug). My issue is rather how to get a reasonable value to set in the setTableQualifier method. I would like to set the name of the (default) schema used in the test setup in order to execute a statement like SELECT <NAME_OF_DEFAULT_SCHEMA>.SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL instead of SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL. In my local test setup, I know that value of course, so that I could hardcode it for testing - but how can I do it in general? A mandatory additional property in the test.property is ugly. An optional property (skipping the test if the property is not set) would basically disable the test for everyone not knowing that property (i.e. everyone except me...). Hmm. Any other ideas? It might be possible to unwrap the JDBC connection, send a query down the connection and get the schema from the ResultSetMetadata. Created attachment 210304 [details]
Test case for sequence object with schema name set plus patch for MaxDB platform
Thanks Tom. I've just uploaded a new patch containing both a test case reproducing the issue and a fix for the MaxDB platform. I placed the test in the ...jpa.advanced.EntityManagerJUnitTestSuite - don't know whether that's a suitable location for it. The patch has been tested successfully on MaxDB and MySQL (where the test is actually skipped). I don't have an Oracle DB available, so unfortunately I couldn't test on that platform. As we need the patch for 2.3 as well: How do you organize that? Should I manually provide a 2.3 patch here or do you have some more sophisticated tooling to downport changes? Please let me know if there's anything else I can actively provide for that patch. Thanks and best regards, Sabine The changes look good to me. We do not have any tools (beyond the typical SVN toolset) for merging changes into previous streams. Most of the time it is a manual process. I assume one of the SAP committers will be committing this. Actually I don't think there really is a SAP committer left... *sigh* Adrian has moved to a different team and is no longer involved with persistency (I think he had informed you about that?). The same with Andreas, who had left long before Adrian. So, may I kindly ask you to commit that for me, please? :-) Thanks and best regards, Sabine Fix checked in to trunk and 2.3 Reviewed by Tom Ware - reviewed Sabine's fix Testing is added in EntityManagerJunitTestSuite as part of the patch Fix checked in by Tom. Thank you for your help! The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
If the application sets a table qualifier (using a session customizer), the SQL statement for accessing a sequence on MaxDB is incorrectly rendered. The table qualifier is duplicated: SELECT ECLIPSELINK.ECLIPSELINK.SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL The reason for this is that both MaxDBPlatform.buildSelectQueryForSequenceObject and NativeSequence.buildSelectQuery add the table qualifier to the sequence name. The attached patch removes the table qualifier from the MaxDBPlatform. I would actually like to add a regression test for this, but I don't know how to integrate the table qualifier into your test framework. Could someone please help? This is how to reproduce the issue: Have a test entity with a sequence: @Entity public class MyEntity { @Id @GeneratedValue(strategy = SEQUENCE) private int id; (...) } Implement a session customizer like that: public class TestSessionCustomizer implements SessionCustomizer { @Override public void customize(Session session) throws Exception { String schemaName = "ECLIPSELINK"; session.getPlatform().setTableQualifier(schemaName); } } Declare it in the persistence.xml: <property name="eclipselink.session.customizer" value="test.TestSessionCustomizer"/> Create and persist the entity: EntityManagerFactory emf = Persistence.createEntityManagerFactory("testmodel"); EntityManager em = emf.createEntityManager(); try { MyEntity e = new MyEntity(); em.getTransaction().begin(); em.persist(e); em.getTransaction().commit(); em.clear(); } finally { emf.close(); }