Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Steve Ebersole
@sebersole
ok apparently i really cannot switch to compose mode. awesome gitter

Hey, can anyone please explain why @LazyToOne(PROXY) eagerly loads singlar attributes, while @LazyToOne(NO_PROXY) doesn't?

https://hibernate.atlassian.net/browse/HHH-14500 maybe?

Steve Ebersole
@sebersole
fwiw I am looking at that later this week
7 replies
antunonline
@antunonline
Hi!
I have a question related to JPA aggregations.
How can this be written with Hibernate?
select date, sum(delta)
from (select cat                 as category,
             ts::date            as date,
             max(val) - min(val) as delta
      from val_table
    where ts between ? and ?
      group by date,cat) as deltas
group by date
Steve Ebersole
@sebersole
you realize Hibernate is a JPA implementation, right?
I'm curious... do people even read the subject here and see that this is not the place to ask questions?
Maybe I need to make the subject even more explicit?
antunonline
@antunonline
Make it more explicit, write "Do not ask questions here".
Thanks!
Steve Ebersole
@sebersole
so the only thing I'm not sure about is ts::date. but that's not even JPA
is that trying to apply a "conversion" or something?
the only defined usage of : in JPA's query BNF is for defining named parameters
and even ? wont work
so not sure why you say this is a JPA query. its not
r_mohan
@r_mohan_twitter
It is able @Embeddable and I use JPA. I have a 'read' model for the UI. The 'write' to the history tables can happen separately. The query separation needs the 'read' model. I read that @Embeddables for the 'read' model have an advantage when a second-level cache is in effect. They are stored entirely in the cache( or something like that). Haven't verified it. Is this an advantage for a 'read' model for the UI ?
r_mohan
@r_mohan_twitter
Should I use @Embeddable for read and write ? These embeddable can be updated or inserted. Not deleted. And only the UI queries them for display. No other transactions involving them are needed.
Harikesh Pallantla
@harikesh409
can anyone tell me how to calculate percentage using CriteriaQuery
Mehmet
@mehmetcc
I have an entity A, mapped to entity B with bidirectional One-To-One association, and in the entity B there is a Set of Enums which I had coupled to B with @ElementCollection
This works for retrieving and inserting into the database, however deletion seems buggy that Hibernate somehow deletes entity A and the Set tables, but doesn't do anything about the B
Is this a bug or am I missing something?
aasifkhan7
@aasifkhan7
using entity manager, can i write a query that takes two fetches data from tables in separate databases?
fabian-froehlich
@fabian-froehlich

Hello there,
not sure if it is the right place to ask, but we found a serious issue with logging of an Exception:

HHH000315: Exception executing batch [java.sql.BatchUpdateException: Batch entry 0 insert into table (colum1, column2, columnn) values ('paylpad1', 'payload2', PERSONAL_INFORMATION)  was aborted: An I/O error occurred while sending to the backend. Call getNextException to see other errors in the batch.], SQL: insert into table (colum1, column2, columnn) values (?, ?, ?)",

This is reported to our logging stack and would be stored for a long period of time. But we are not allowed to store personalInformation in that storage for that time.
So we guessed that, there could be an option to mask columns in Exceptions due sensible information. But we did not found something related to that. The way around would be to change the Logback ConsoleAppender. But is there something alread inside Hibernate to do that?

fabian-froehlich
@fabian-froehlich
Logger-Name: logger_name: org.hibernate.engine.jdbc.batch.internal.BatchingBatch and org.hibernate.engine.jdbc.spi.SqlExceptionHelper
nivinps
@nivinps

Dear @sebersole @DavideD
I am using reactive hibernate (1.0.0.CR7) for my spring webflux project. I am getting the object array data while executing native queries and it is working fine. But I need it as a tuple object. So I passed Tuple.class argument to createNativeQuery method. But it will throw an exception as it cannot cast an object to tuple. I just need the data with column names. So I choose tuple instead of object array. Kindly help.

Sample code:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("Persistence");
Mutiny.SessionFactory sessionFactory = emf.unwrap(Mutiny.SessionFactory.class);
Mutiny.Session session = sessionFactory.openSession();
String str = "select c.country_name as country_name, c.phone_code as phone_code
from erp_country c"; // MySql query
Mutiny.Query<Tuple> query = session.createNativeQuery(str, Tuple.class);
List<Tuple> list = query.getResultList().await().indefinitely();
for (Tuple tuple : list) { // here it will throw an exception as object cannot be cast to class javax.persistence.Tuple
System.out.println(tuple.get("country_name") + "-" + tuple.get("phone_code"));
}

Exception Message:

Ljava.lang.Object; cannot be cast to class javax.persistence.Tuple ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; javax.persistence.Tuple is in unnamed module of loader 'app')

Davide D'Alto
@DavideD
@nivinps
the second parameter of createNativeQuery or createQuery must be an entity class. You cannot use Tuple.
But you can omit it and Hibernate Reactive will return an array of objects:
Davide D'Alto
@DavideD
Sorry, a list of array of objects
List<Object[]> results = session.createNativeQuery(str).getResultList().await().indefinitely();
for (Object[] tuple : results ) {
    String countryName = tuple[0];
    Object countryCode = tuple[1];
}
I would also upgrade to Hibernate Reactive 1.0.0.CR8
Steve Ebersole
@sebersole
Please dont ping people randomly, directly for questions. E.g. I have (nor want) zero to do with Reactive
nivinps
@nivinps

@DavideD
thank you for your response.

I have another project using JPA- hibernate 5.5. There I can pass the second parameter of createNativeQuery as tuple class instead of giving an entity class. So I thought may be there is a chance to use Tuple in reactive hibernate also. If we use tuple class then we can retrieve the data by using alias name in the query string.
Few reference:
https://stackoverflow.com/questions/44626609/getting-column-names-from-a-jpa-native-query
https://stackoverflow.com/questions/16296853/jpa-result-list-cast-object-to-tuple

Anyway, I will go with object array as you have mentioned.

@sebersole Sorry.
Davide D'Alto
@DavideD
The javadoc is vague about which type actually works and I didn't realize you could pass a Tuple. @nivinps Could you create an issue on GitHub for Hibernate Reactive? https://github.com/hibernate/hibernate-reactive/issues
That's also a better place to ask questions about Hibernate Reactive. Here you should ask questions about Hibernate ORM
@nivinps Thanks for the feedback by the way :)
nivinps
@nivinps
@DavideD Sure. I will create an issue on GitHub. Thank you for your guidance and support :)
@Naros
Artem Utkin
@artemoons
Hello! Can you please tell me if I need to manually add hibernate-hikaricp dependency if I work with Spring Boot 2 (where HikariCP is included by default)? I searched this question in many sources but not 100% sure that it's not needed.
James Howe
@OrangeDog
Anyone have any insight here?
pgjdbc/pgjdbc#2323
How does hibernate determine the type via JDBC?
Steve Ebersole
@sebersole
not exactly sure what "determine the type via JDBC" means in this context. also, as mentioned in the room title, we generally do not monitor this chat. you should really ask such questions on our Zulip chats
i just happened to notice because i came to gitter for another teams chat
James Howe
@OrangeDog
I mean some code to demonstrate a difference using the JDBC API without Hibernate.
I'll head over there.
Well that's a confusing chat app :(
Steve Ebersole
@sebersole
if you say so
i guess it takes a little getting used to, but the topics are very helpful
Marc Magon
@GedMarc
Hey All,
Anyone found the bytebuddy update after 1.11.13 fails for the hibernate-enhancer? SuffixNameResolver no longer exists as a class in the library?