Ganesh Choudhary

Greenhorn
+ Follow
since Sep 11, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ganesh Choudhary

I have tried to intercept method calls by enhancing method body. e.g original method is something like this :

i enhanced the method body using BCEL. Enhanced method will look like :

In this way i am able to intercept the getName() method call.
Now I want to intercept field access. Let us consider the Person class contains this getName() method. and the variable "name" of this class will be accessed like this :

I want to intercept this variable access. How can i proceed ?? Can anyone help me please.

Thanks,
Ganesh


While building the sessionFactory hibernate is not able to locate your entity class.

Thanks,
Ganesh
I can set one to one relation from hbm file using constrained="true" lazy="proxy" but the same thing i am trying to do from configuration Object using :

But i am to able to set it lazy . Although it breaks the Join , i mean to say, when i am using above code snippet hibernate fires a second select query to find the associated one-to-one entity. I want to change this immediate second select query to Object Navigation query(i.e set lazy).

Any view ? any idea ?

Thanks,
Ganesh
You will have to create the object of TestRunner Class in your servlet and then call the run method on this object. Then Pass the TestRunnerResult Object to create the object of OutputProducer class . Call render() method on this object of OutputProducer Class.

You can go through the sample code of JUnitEEServlet at :
[url]http://demo.spars.info/j/frameset.cgi?compo_id=345268&packagename=org.junitee.servlet&componame=org.junitee.servlet.JUnitEEServlet&mode=frameset&ref=5&start_class=0&location=1111111111111111111&CASE=0&MORPHO=1&LANG=1&q=jsp&hl=jsp&compo_id=345269
[/url]

Thanks.
14 years ago
I have 4 classes : Reservation, Disc (abstract class), AudioDisc, VideoDisc(both extending Disc Class).









Reservation.hbm.xml



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="tableperconcretesubclass.Reservation" table="DB2ADMIN.RES_Test">
<id name="id" type="integer" column="ID" >
<generator class ="assigned"/>
</id>
<!-- <many-to-one name="disc" class="tableperconcretesubclass.Disc" column="DISC_ID" /> -->
<!-- <one-to-one name="disc" class="tableperconcretesubclass.Disc" /> -->

<property name="description" type="string" column="DESCRIPTION"></property>

<set name="discs" lazy="true" cascade="all" >
<key column="DISC_ID" />
<one-to-many class="tableperconcretesubclass.Disc"/>
</set>
</class>
</hibernate-mapping>



Disc.hbm.xml :



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="tableperconcretesubclass.Disc" abstract="true">
<id name="id" type="integer" column="ID" unsaved-value="0">
<generator class ="sequence"/>
</id>

<union-subclass name="tableperconcretesubclass.AudioDisc" extends="tableperconcretesubclass.Disc" lazy="false" table="DB2ADMIN.AUDIODISC_Test">

<property name="singer" type="string" column="SINGER" />
<property name="numOfSongs" type="int" column="NUM_OF_SONGS"/>
<set name="songs" lazy="true" cascade="all" >
<key column="AUDIODISC_ID" />
<one-to-many class="tableperconcretesubclass.Song"/>
</set>
</union-subclass>
<union-subclass name="tableperconcretesubclass.VideoDisc" extends="tableperconcretesubclass.Disc" lazy="true" table="DB2ADMIN.VIDEODISC_Test">
<property name="director" type="string" column="DIRECTOR" />
<property name="language" type="string" column="LANG"/>
</union-subclass>
</class>
</hibernate-mapping>



Song.hbm.xml :



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="tableperconcretesubclass.Song" table="DB2ADMIN.SONG_Test">
<id name="id" type="integer" column="ID" >
<generator class ="assigned"/>
</id>
<property name="title">
<column name="TITLE" />
</property>

<property name="movie">
<column name="MOVIE" />
</property>

</class>
</hibernate-mapping>





when i am running createEntity() method with property

<property name="hibernate.hbm2ddl.auto">create</property>



i am getting following exception :



I am not getting why it is trying to create DISC table when Disc class is abstract ? am i doing anything wrong ? Can anybody please help me ?

Thanks
I have a super class Disc and two child classes : AudioDisc and VideoDisc. I am trying both the strategy Union subclass and join Subclass but i could not find any way to lazy load the subClass.

My classes are something like this :




Now when i am calling
List<Reservation>reservations = query.list();
in main()
and calling getDiscs() overs each reservation object the sql is fired to join or union (based on the strategy defined in mapping) to fetch the data from DB. can we set the lazy loading of these subclass ?? i mean to say that the sql corresponding to that subclass should not be fired untill we have not accessed the property of the class . If it is not possible then what is the use of providing the lazy attribute in the metadata definition of joinsubclass or unionsubclass (which holds the default value "false").

Any help is appreciated .

Thanks.
I want something to execute on openSession and closeSession event of hibernate. When Hibernate API is used to persist the object i am able to do it . I have put aspects around openSession() and closeSession() methods and there i can execute my own logic but when Java Persistence API is used to persist an object i am not able to do it. when we call the close() method on entityManager's object it goes to aspect i have put on session.close() method but it never goes to the aspect put on openSession() event. so what to do ?? Can you people please help me ?

Thanks,
Ganesh

Adam Michalik wrote:Have a look at the AspectJ pointcut reference - get/set(FieldPattern) seems what you are looking for.



Thank You very much Man !!! it's working fine now . I have used get and set pointcut for my purpose ...
14 years ago
any idea where to put aspect ??? i mean to say that on which method of which class i will have to put the aspect ??? actually i have tried to debug the above code but on pressing F5 it doesn't go to any internal method call so i am not getting on which method i should use the aspect ...
14 years ago
That's what i am doing in the case of private variable . i am instrumenting the Getters and Setters of the corresponding variable in that case . but i don't know what to do in the case of a public variable.
14 years ago
Hi all,

I have two Java Classes as follows :


and --


Now i want to generate a log file (when the execution of main() method of class B ends) which tells me that "THE VARIABLE NAMED 'a' OF CLASS 'A' IS ACCESSED ONCE" .

PLEASE NOTE THAT I DON'T HAVE PERMISSION TO MODIFY THE SOURCE CODE OF EXISTING CLASS ..

So please tell me how to proceed to get the solution ..

Thanks.
Ganesh
14 years ago