Phil 12.29.15

7:00 – 5:30 VTX

  • Finished Social Media and Trust during the Gezi Protests in Turkey.
  • More Hibernate
    • After stepping through the ‘Showroom’ example on pg 54 (Using a Join Table), of Just Hibernate I think I see my problem. In my case, the corpus has already been created and exists as an entry in the corpora table. I need to add a relationship when a word is run against a new corpus. Which come to think about it, should have the word count in it. Maybe?
    • Ok, I don’t like the way that ManyToMany is implemented. Hibernate should be smart enough to figure out how to make a default mapping table. Sigh.
    • And you have to call each object with the other object or it doesn’t load properly.
    • After being annoyed for a while, I decided to try reflection as a making fewer calls. The following still needs the get/set member element calls, but I like the direction it’s going. Will work on it some more tomorrow (need to add the call on the this class):
      public void addM2M(Object obj){
          Class thisClass = this.getClass();
          String thisName = thisClass.getName();
          Class thatClass = obj.getClass();
          Method[] thatMethods = thatClass.getMethods();
          Method thatMethod = null;
          for(int i = 0; i < thatMethods.length; ++i){
              Method m = thatMethods[i];
              Type[] types = m.getGenericParameterTypes();
              if (types.length == 1) { // looking for one arg setters
                  for (int j = 0; j < types.length; ++j) {
                      Type t = types[j];
                      if ((t.getTypeName() == thisName)) {
                          thatMethod = m;
              if(thatMethod != null){
          if(thatMethod != null){
              try {
                  thatMethod.invoke(obj, this);
              } catch (IllegalAccessException e) {
              } catch (InvocationTargetException e) {
                  System.out.println("addM2M failed: "+e.getCause().getMessage());

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s