Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Null attribute classification

Thank you for investigating this so thoroughly and replying back.  I'll try to test with Spring 2.5.5 and will report if I'm successful.

On Sun, Oct 26, 2008 at 04:59, Gaurav Malhotra <gaurav.malhotra@xxxxxxxxxx> wrote:

Hi I just verfied the change log of spring 2.5.5 and found that appropriate
changes (mainly proxy creation in EclipseLinkVendorAdater/Transaction mgmt)
has been done and hence should not result in
"org.springframework.dao.InvalidDataAccessApiUsageException" [which if comes
should be a problem in persitence framework]

Here is my Spring JUnit 4 test case and its working fine. [JPQL works like
charm :-)]

@Test
@Transactional(propagation=Propagation.NOT_SUPPORTED)
@Order(value = 6)
public void fireJpqlQryAndValidateL2CacheIsHit() {
JpaDaoSupport jpaDao = (JpaDaoSupport) genericDao;
Assert.assertNotNull(jpaDao);
jpaDao.getJpaTemplate().execute(new JpaCallback() {
@SuppressWarnings("unchecked")
public Object doInJpa(final EntityManager em) {
String sql = "select p from Publisher p where p.id = 1";

Query query =em.createQuery(sql);
List<Publisher> list = query.getResultList();
Assert.assertNotNull(list);
Assert.assertTrue(list.size() > 0);
return null;
}
});

I  hope it helps

}

Here is code snippet how the test class should be decorated with Junit 4
(using spring)

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath:META-INF/spring/spring-jpa-applicaiton-context.xml" })
@TransactionConfiguration(transactionManager = "transactionManager",
defaultRollback = false)
@Transactional(propagation=Propagation.REQUIRES_NEW)
public class MyServiceTest


Gaurav Malhotra wrote:
>
> Hi,
>   I remember getting this error in the Hiberate earlier version and then
> went away. I really investiaged it that time and my conclusion based was
>
> "Exception thrown on incorrect usage of the API, such as failing to
> "compile" a query object that needed compilation before execution.
> This represents a problem in our Java data access framework, not the
> underlying data access infrastructure. " [This is in accordance with Rod
> Johoson]
>
> Intrestingly if I use ReadAllQuery in place of JPQL it goes away
>
> Hence it seems there is a  problem in the Java data access framework when
> using with spring and using JPQL query
>
> [I am using Spring 2.5.5.A + eclipse link 1.0.1 + JUnit 4.4 annotation
> based tx]
>
>
>
> Carl Hall-2 wrote:
>>
>> I get the following error when trying to load up my orm.xml files:
>>
>> Caused by: Exception [EclipseLink-8030] (Eclipse Persistence Services -
>> 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.JPQLException
>> Exception Description: Error compiling the query [select p from Poll p
>> where
>> p.siteId = ?1 order by p.creationDate desc], line 1, column 29: unknown
>> state or association field [siteId] of class
>> [org.sakaiproject.poll.model.Poll].
>>     at
>> org.eclipse.persistence.exceptions.JPQLException.unknownAttribute(JPQLException.java:450)
>>     at
>> org.eclipse.persistence.internal.jpa.parsing.DotNode.validate(DotNode.java:77)
>>     at
>> org.eclipse.persistence.internal.jpa.parsing.Node.validate(Node.java:91)
>>     at
>> org.eclipse.persistence.internal.jpa.parsing.BinaryOperatorNode.validate(BinaryOperatorNode.java:34)
>>     at
>> org.eclipse.persistence.internal.jpa.parsing.EqualsNode.validate(EqualsNode.java:41)
>>     at
>> org.eclipse.persistence.internal.jpa.parsing.WhereNode.validate(WhereNode.java:34)
>> <snip/>
>>
>> siteId is in my mapping definition for Poll (see below) and I don't get
>> any
>> errors when starting up the application just when I try to call the query
>> noted above.  I've walked the code down to the point where
>> TypeHelperImpl.getType(DatabaseMapping) eventually has "type =
>> mapping.getAttributeClassification()" which leaves type as null.  What
>> can I
>> do to get this type to not be null?
>>
>> Part of Poll.orm.xml:
>> <entity metadata-complete="true" name="Poll"
>> class="org.sakaiproject.poll.model.Poll">
>>     <table name="POLL_POLL"/>
>>     <attributes>
>>       <id name="id">
>>         <column name="POLL_ID"/>
>>         <generated-value strategy="SEQUENCE"
>> generator="POLL_POLL_ID_SEQ"/>
>>         <sequence-generator name="POLL_POLL_ID_SEQ"
>> sequence-name="POLL_POLL_ID_SEQ"/>
>>       </id>
>>       <basic name="owner">
>>         <column name="POLL_OWNER" nullable="false"/>
>>       </basic>
>>       <basic name="siteId">
>>         <column name="POLL_SITE_ID" nullable="false"/>
>>       </basic>
>>   </attributes>
>> </entity>
>>
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Null-attribute-classification-tp20136549p20171435.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top