I just tried:

       Query q = getHibernateSession(context).createSQLQuery("SELECT * FROM
EPerson  WHERE uuid in (SELECT proxy_id from proxies where depositor_id = '"
+ depositor_id.toString() + "')");

       q.setResultTransformer(Transformers.aliasToBean(EPerson.class));

       List<EPerson> results = q.list();

       return results;



And I'm getting:


org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111


in this line:

       List<EPerson> results = q.list();



On Mon, Feb 24, 2020 at 5:26 PM Jose Blanco <blan...@umich.edu> wrote:

> Kind of stuck trying to create a query without having to map it.  This is
> what I have:
>
>     @Override
>
>     public List<EPerson> findProxiesForDepositor(Context context, UUID
> depositor_id) throws SQLException {
>
>
>
>         Query query = getHibernateSession(context).createSQLQuery("SELECT
> * FROM EPerson WHERE uuid in (SELECT proxy_id from proxies where
> depositor_id =:depositor_id)");
>
>         query.addEntity(EPerson.class);
>
>         query.setParameter("depositor_id", depositor_id);
>
>
>         List<EPerson> epersons = query.list();
>
>
>         return epersons;
>
>
>     }
>
>
> It's telling me that :
>
>
> [ERROR] EPersonDAOImpl.java:[187,14] cannot find symbol
>
> [ERROR] symbol:   method
> addEntity(java.lang.Class<org.dspace.eperson.EPerson>)
>
> [ERROR] location: variable query of type org.hibernate.Query
>
>
> I found something on the web that suggested I could do it this way.
>
>
> If someone could correct this query, that would really help me because I
> have others like it.
>
>
> Thank you!
>
> -Jose
>
>
>
> On Thu, Feb 20, 2020 at 4:01 PM Tim Donohue <tim.dono...@lyrasis.org>
> wrote:
>
>> Hi Jose,
>>
>> There is one example of createNativeQuery() in the DSpace codebase itself
>> here:
>>
>>
>> https://github.com/DSpace/DSpace/blob/master/dspace-api/src/main/java/org/dspace/eperson/dao/impl/GroupDAOImpl.java#L170
>>
>> I'm sure you could find more examples via Google or StackOverflow as well.
>>
>> Tim
>>
>> ------------------------------
>> *From:* Jose Blanco <blan...@umich.edu>
>> *Sent:* Thursday, February 20, 2020 2:28 PM
>> *To:* Tim Donohue <tim.dono...@lyrasis.org>
>> *Cc:* DSpace Technical Support <dspace-tech@googlegroups.com>
>> *Subject:* Re: [dspace-tech] new table in 6.3
>>
>> Looking for an example.  I wonder if someone in the community has done
>> this. I think using createNativeQuery() would be preferable.  I have 4
>> tables that are not part of the dspace code that I need to manipulate.
>>
>> Thanks!
>> -Jose
>>
>> On Thu, Feb 20, 2020 at 1:01 PM Tim Donohue <tim.dono...@lyrasis.org>
>> wrote:
>>
>> Hi Jose,
>>
>> That error from Hibernate usually means that you are trying to run a
>> straight SQL query when it's expecting you to use HQL (Hibernate Query
>> Language) and a Hibernate Entity object.  So, more than likely you need to
>> do one of the following:
>>
>>
>>    - Either, Create a Hibernate Entity class that maps to this Table.
>>    See
>>    
>> https://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html
>>  This
>>    is how DSpace 6.x (and above) already maps to existing tables...you'll see
>>    an Entity object corresponding to every table in the codebase.
>>    - Or, you might be able to tell Hibernate this is just a plain old
>>    SQL query by using Hibernate's "createNativeQuery()" method instead of
>>    using "createQuery()" (as the latter expects a Hibernate Entity).  More
>>    info on that is at
>>    https://docs.jboss.org/hibernate/core/4.0/hem/en-US/html/query_native.html
>>
>>
>> Hopefully that helps.
>>
>> Tim
>>
>> ------------------------------
>> *From:* dspace-tech@googlegroups.com <dspace-tech@googlegroups.com> on
>> behalf of Jose Blanco <blan...@umich.edu>
>> *Sent:* Thursday, February 20, 2020 10:42 AM
>> *To:* DSpace Technical Support <dspace-tech@googlegroups.com>
>> *Subject:* [dspace-tech] new table in 6.3
>>
>> I have a new table in 6.3 - individual_stats, and I'm seeing this error:
>>
>> org.hibernate.hql.internal.ast.QuerySyntaxException: individual_stats is
>> not mapped [SELECT count(*) FROM individual_stats WHERE email='
>> blan...@umich.edu']
>>
>> How do I map indiviual_stats table?
>>
>> Thank you!
>> -Jose
>>
>> --
>> All messages to this mailing list should adhere to the DuraSpace Code of
>> Conduct: https://duraspace.org/about/policies/code-of-conduct/
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "DSpace Technical Support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to dspace-tech+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/dspace-tech/CAK%3DKc-uyfZ8QofBe2Mo9WKyPDSAA8vvOgh4HfsAM%3DJWGPFsNNw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/dspace-tech/CAK%3DKc-uyfZ8QofBe2Mo9WKyPDSAA8vvOgh4HfsAM%3DJWGPFsNNw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>>

-- 
All messages to this mailing list should adhere to the DuraSpace Code of 
Conduct: https://duraspace.org/about/policies/code-of-conduct/
--- 
You received this message because you are subscribed to the Google Groups 
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dspace-tech+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dspace-tech/CAK%3DKc-sdG3d5Qj%3Dwy_vs9jtv0LOTtXgnTTcNUHrJRzD68j1eMg%40mail.gmail.com.

Reply via email to