49 پاسخ به “آموزش خواب زمستانی 12 – انواع پروکسی و انواع مشتاق و مشتاق”

  1. Hi Koushik, excellent tutorials as usual, but I have a doubt : when I print the class of the retreived object using session.get(), it still shows the original class, and not some proxy class, why is this ?

  2. After session.close() if you r trying to fetch user.getName() it is showing the name?.How is it possible? because after session close all objects will be clear from cache

  3. Amigo,
    estou recebendo o seguinte erro quando tento fazer um GET em tabelas que possuem relacionamento:
    "java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: org.hibernate.proxy.HibernateProxy. Forgot to register a type adapter?"

    A meu ver a biblioteca Gson está tendo problemas ao receber a lista de objetos e converter para JSON. Sabe como resolver isso?

    Obrigado.

  4. good tutorial indeed. However still did not get why Colletion Interface is used instead of collection implementation. In previous session it was said that it will be explained here.

  5. Hibernate doesnt fire the select query if you just call user.getListOfAddresses(). it calls only when you are trying to get information of data inside collection like user.getListOfAddresses().size().
    By writing user.getListOfAddresses() will print only the proxy object without the select being fired.
    Also there is no proxy of User class, instead the proxy object of collection is created.

  6. You say the list is fetched when the getter is called, but I believe it is when the list is actually used :
    user.getListOfAdresses(); // nothing is fetched
    user.getListOfAdresses().size(); // list is fetched

  7. I think session.get do not create proxy. Reasons are : 1.If constructor of userDetails entity is private then it will generate exception when we use session.load same scenario with session.get not throw exception.
    2. For session.load JavassistProxyFactory creates proxy but in case of session.get there is a condition in Entity.class of hibernate. Below condition is false.
    if ( proxyOrEntity instanceof HibernateProxy ) {
    ( (HibernateProxy) proxyOrEntity ).getHibernateLazyInitializer()
    .setUnwrap( isProxyUnwrapEnabled );
    }

    Also the fetchType is related to Collection as shown in @OneToMany (By default Lazy for @OneToMany and @ManyToMany)
    due to which lazy initilization exception was thrown. hese 2 things are different as per my understanding.

  8. Yep as I said before the program has a problem for me.
    If I run it twice the second time I run it hangs on
    Hibernate: alter table USER_ADDRESS drop constraint FK_rr7b0tc5khp6fevg5vf9ctn5

  9. @Java Brains
    One thing that puzzles if this Proxy class extends a base class.  You cast using a base class cast would you not be calling functions from the base class?

  10. Hi koushik first of all, thank you very much for providing such a great tutorials. You are awesome.!! I am confused that I learned session.load() will only return a proxy object while session.get() will return real object that is instance of user class . But as you said in the video proxy object of user class is returned by session.get(). I am having confusion over here. Thanks 

  11. Hi
    As we will reach to user.getAddress, will load 100 of addresses but is there any way where I can specify to load the addresses who lives in bombay.
    in this I can only think of writig a query which get the data of bombay location, is there any other way in hibernate itself

  12. Hi Koushik! Thank u for such great tutorials.
    I have a question, kindly clarify.
    1) Instead of session.get, if we use session.load, unless we access the non-primary entities of a model/POJO class, no fetching is done from the db. Can this also be called a lazy fetching?
    2) With sesion.load, even if Fetchtype=Eager, trying to fetch a collection after closing the session, it still throws an error LazyInitializationException.
    Either case, using session.load is always a LazyFetching. Is that rt?

  13. your lectures are good … I feel you waste lot of time talking … its total unnecessary to go in that detail … this really bored me and made me close video

  14. I read an interesting question on stackoverflow. com/questions/5027013/hibernate-lazy-load-application-design about lazy loading entities in DAO layer. What do you think about?
    Regards. Thanks for your videos.

نظرات بسته شده اند.