Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Question regarding odd behavior of EclipseLink with Derby

Hi Tom,

1. I am certain that both databases have the same data. 
2. The endpoint.addServices(getServicesAtEndpoint(endpoint, q1).getList()); is *not* supposed to cause any inserts into the database because the 'services' field within 'endpoint' is transient. In my orm.xml there is no attribute called 'services' inside 'endpoint'. However, I had forgotten to make the 'services' field transient in the java code using @Transient annotation. After I made it transient in the java code using @Transient annotation, the problem disappeared. 

So the problem is solved but I wonder why the problem only shows up when I use derby (also h2 database) but not postgresql. Anyway, I will make it to point to mark all transient fields using the @Transient annotation.

Thanks

Gopi

On Jan 20, 2010, at 12:47 PM, Tom Ware wrote:

> Hi Gopi,
> 
>  Are you certain both databases have the same data?
> 
>  I would expect this code to cause the same behavior regardless of the db:
> 
>            for (Endpoint endpoint : results) {
>                Qualifier q1 = new QualifierImpl();
>                endpoint.addServices(getServicesAtEndpoint(endpoint, q1).getList());
>            }
> 
>  If you are certain the data is the same, try removing the query.getFirstResult() and the query.getMaxResults() since those are the only two pieces of code that strike me as DatabasePlatform specific.
> 
>  If the data is different, try again with similar data and have a look at the mapping between EndPoint (and any subclasses) and ServiceQualifiedList.  That seems to be the relationship that has a relation table.
> 
> -Tom
> 
> Gopi Kandaswamy wrote:
>> Hi Tom,
>> With reference to my previous email, please find attached a new 'code.txt' file. Please use this 'code.txt' instead of the 'code.txt' from the previous email.
>> Thank you,
>> Gopi
>> ------------------------------------------------------------------------
>> On Jan 20, 2010, at 10:48 AM, Tom Ware wrote:
>>> Hi Gopi,
>>> 
>>> From what I can see, Derby and PostgreSQL are succeeding at running exactly the same SQL.  Derby simply runs code after the successful code that causes the failure.
>>> 
>>> Can you please post the code you are running in both environments?  When I look at the logs, I see a successful INSERT - perhaps the result of your persist.  After the insert, the transaction commits, and more SQL is run.  Are you running some queries? ("Service.countServicesAtEndpoint", "Service.getServicesAtEndpoint")  What do those queries do?  What code is run around the times when those queries are run?  What happens after those queries are run (is there something that modifies an object and either does a flush of a commit?
>>> 
>>> 
>>> 
>>> -Tom
>>> 
>>> Gopi Kandaswamy wrote:
>>>> Hi Tom,
>>>> Thank you for your help. Please find attached two files; one with the derby logs (derby-log.txt) and the other with the postgresql logs (postgres-log.txt). As I had mentioned before, the problem occurs when I try to persist the 'Service' object and so I have included the logs for just that. As you can see the persist operation works fine in postgresql but fails in derby.
>>>> Note: 1. The relation between Service (maps to table called physical_endpoints) and Endpoint (maps to table logical_endpoints) is of type 'many-to-one' as specified in the orm.xml.
>>>> 2. I have attached the relevant portions of my pom.xml file (pom.xml) to tell you which versions of what libraries I am using.
>>>> Thank you very much in advance.
>>>> Gopi
>>>> ------------------------------------------------------------------------
>>>> ------------------------------------------------------------------------
>>>> ------------------------------------------------------------------------
>>>> On Jan 20, 2010, at 7:09 AM, Tom Ware wrote:
>>>>> Hi Gopi,
>>>>> 
>>>>> Could you turn on logging and send the logged SQL from both your Derby and PostGreSQL test cases?  (persistence unit property: eclipselink.logging.level=FINEST)
>>>>> 
>>>>> Please also include the full stack trace from the exception in Derby.
>>>>> 
>>>>> -Tom
>>>>> 
>>>>> Gopi Kandaswamy wrote:
>>>>>> Hi all,
>>>>>> I am using EclipseLink 2.1.0 and when I run my code against a Derby database, I get the following error message. Basically this is what is happening...
>>>>>> a) I have a class called 'Service' (maps to database table called physical_endpoints) which has a many-to-one relationship to a database table called logical_endpoints. So the orm.xml for physical_endpoints looks like this...
>>>>>> <entity class="Service">
>>>>>> 	<table name="physical_endpoints" />
>>>>>> 	<attributes>
>>>>>> 	.
>>>>>> 	.
>>>>>> 	.	
>>>>>> 	<many-to-one name="endpoint">
>>>>>>     	<join-column name="logical_id" />
>>>>>> 	</many-to-one>
>>>>>>     </attributes>
>>>>>> </entity>
>>>>>> As you can see, I have specified a <join-column name="logical_id">. I have not specified a <join-table name="the_join_table_name"> because such a join table does not exist and I do not want such a table to be created automatically by JPA. But when I run my code, EclipseLink tries to insert records into the join table for the above relationship. The join table for the above relation does not exist and hence the error below. The weird thing here is that when I use PostgreSQL database instead of Derby database, the following exception does not occur. In other words, the error occurs when I use EclipseLink + Derby and not EclipseLink + PostgreSQL.
>>>>>> Does anyone have any ideas? The error below occurs when I persists (em.persist(service)) to the database.
>>>>>> Thanks
>>>>>> Gopi
>>>>>> =======Exception=========
>>>>>> Internal Exception: java.sql.SQLSyntaxErrorException: Table/View 'LOGICAL_ENDPOINTS_PHYSICAL_ENDPOINTS' does not exist.
>>>>>> Error Code: 20000
>>>>>> Call: INSERT INTO logical_endpoints_physical_endpoints (services_id, Endpoint_id) VALUES (?, ?)
>>>>>> 	bind => [1, 1]
>>>>>> Query: DataModifyQuery(sql="INSERT INTO logical_endpoints_physical_endpoints (services_id, Endpoint_id) VALUES (?, ?)")
>>>>>> =========================_______________________________________________
>>>>>> eclipselink-users mailing list
>>>>>> eclipselink-users@xxxxxxxxxxx
>>>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>>> _______________________________________________
>>>>> eclipselink-users mailing list
>>>>> eclipselink-users@xxxxxxxxxxx
>>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>> ------------------------------------------------------------------------
>>>> _______________________________________________
>>>> eclipselink-users mailing list
>>>> eclipselink-users@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>> _______________________________________________
>>> eclipselink-users mailing list
>>> eclipselink-users@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>> ------------------------------------------------------------------------
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top