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 <[email protected]> Sent: Thursday, February 20, 2020 2:28 PM To: Tim Donohue <[email protected]> Cc: DSpace Technical Support <[email protected]> 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 <[email protected]<mailto:[email protected]>> 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: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>> on behalf of Jose Blanco <[email protected]<mailto:[email protected]>> Sent: Thursday, February 20, 2020 10:42 AM To: DSpace Technical Support <[email protected]<mailto:[email protected]>> 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='[email protected]<mailto:[email protected]>'] 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 [email protected]<mailto:[email protected]>. 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/CY4PR2201MB11431A47CAB0178181625EDFED130%40CY4PR2201MB1143.namprd22.prod.outlook.com.
