1

I have changes the code but the issue is still there

    CandidateResumeInfo candidateResumeInfo = new CandidateResumeInfo();
    ArrayList<CandidateResumeInfo> allCandidateResumeInfo= new ArrayList<CandidateResumeInfo>();

    Session session = sessionFactory.openSession();
    String city1 ="Anniston";

    Criteria  crit = session.createCriteria(CandidateResumeInfo.class);
    crit.createAlias("candidate", "candidateinfo");

    //crit.setFetchMode("candidateinfo", FetchMode.JOIN);
    crit.add( Restrictions.eq("candidateinfo.city", city1));
    List list = crit.list();

here is the entity class .. public class CandidateResumeInfo implements Serializable{ ...

      @OneToMany     
      CandidateInfo candidate;

      ....
      }
      public class CandidateInfo implements Serializable{
      .......

     @Column(name="city")
     private String city;
      .......
      }

Here are top top few lines of stack trace This is some RPC.class ( it comes at this line which says Throwable cause = e.getCause();and at the right variables side(in debug mode) there's written java.lang.reflect.InvocationTargetException , but there is nothing java.lang.reflect.InvocationTargetException in the stack trace

   public final class RPC {
    .......
   public static String invokeAndEncodeResponse(Object target,
  Method serviceMethod, Object[] args,
  SerializationPolicy serializationPolicy, int flags)
  throws SerializationException {
if (serviceMethod == null) {
  throw new NullPointerException("serviceMethod");
}

if (serializationPolicy == null) {
  throw new NullPointerException("serializationPolicy");
}

String responsePayload;
try {
  Object result = serviceMethod.invoke(target, args);

  responsePayload = encodeResponseForSuccess(serviceMethod, result,
      serializationPolicy, flags);
} catch (IllegalAccessException e) {
  SecurityException securityException = new SecurityException(
      formatIllegalAccessErrorMessage(target, serviceMethod));
  securityException.initCause(e);
  throw securityException;
} catch (IllegalArgumentException e) {
  SecurityException securityException = new SecurityException(
      formatIllegalArgumentErrorMessage(target, serviceMethod, args));
  securityException.initCause(e);
  throw securityException;
} catch (InvocationTargetException e) {
  // Try to encode the caught exception
  //
  **Throwable cause = e.getCause();**   // THIS IS THE LINE WHERE IT BRINGS ME ..

  responsePayload = encodeResponseForFailure(serviceMethod, cause,
      serializationPolicy, flags);
}
junaidp
  • 10,801
  • 29
  • 89
  • 137

1 Answers1

1
crit.createAlias("Class2", "c2").add(Restrictions.eq("c2.zip", 123)

should do it...

If you simply use 'zip' hibernate will look for a property zip in class Class1; it has nothing to do with the property being PK or not.

Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101
  • Thanks, I have changed the code as u said , still not resolved ,kindly review the code above (i have pasted the actual code)and let me know if i'm doing some thing wrong thanks – junaidp May 30 '11 at 09:01
  • `crit.createAlias("CandidateInfo" ...);` if your property is called candidate this should be `crit.createAlias("candidate", ...` – Stijn Geukens May 30 '11 at 09:14
  • changed it ,also edited above ,Issue is still there , Any Suggestion .do i need to do something at some other place as well to make a JOIN. thanks – junaidp May 30 '11 at 09:49
  • Which issue do you face exactly; do you have an exception? – Stijn Geukens May 30 '11 at 09:51
  • at the above line List list = crit.list(); its goes exception java.lang.reflect.InvocationTargetException but if i use candidateinfo.id instead of candidateinfo.city it works fine (as id is the primarykey) ,but i want to link with city not id ,want to set some criteria on city in csndidateinfo class. thanks – junaidp May 30 '11 at 09:58
  • Hibernate will automatically join on the id, there is now way around this but this is ok. You need to join on id and then filter on city. Does your query work without the createAlias and restriction? Append the full stack trace to your question. – Stijn Geukens May 30 '11 at 11:02
  • yes , it does work without createAlias and restriction . i've tried to put full track here but it says text limit exceeded – junaidp May 30 '11 at 11:30
  • @junaidp, see http://benpryor.com/blog/2006/08/15/java-dynamic-proxies-and-invocationtargetexception/ if it helps. For stack trace, you can try putting top few lines. – Reddy May 30 '11 at 12:52
  • thanks , the site didnt help , i have attached the stack trace above ,i dont think it will be useful . if you want i can email you the complete – junaidp May 31 '11 at 04:58
  • This is not the stacktrace but just a part of the logging; we need the part that starts with java.lang.reflect.InvocationTargetException and the caused by's. – Stijn Geukens May 31 '11 at 07:48
  • This is code, still not a stacktrace. [This](http://stackoverflow.com/questions/5110991/java-java-lang-reflect-invocationtargetexception-with-digester-parser) is a stacktrace – Stijn Geukens May 31 '11 at 09:12