org.hibernate.hql.ast.QuerySyntaxException: Class-name is not mapped

In this post i will guide you through how to solve below hibernate exception when using HQL

org.hibernate.hql.internal.ast.QuerySyntaxException: Class-name is not mapped

In my experience has many reasons for that exception. I will guide you step by step to check the issue

1. Check your hibernate config file hibernate.cgf.xml, do you have define that class yet or not in that file.  If you already define please go to next step

2. If you using hibernate mapping file, please naming for that file same as Class name.

3. If your persistence class define with annotation @Entity(name=’entity_name’) so please use that in HQL in case that you use unqualified name for example if your class is SystemParameter but you annotation @Entity(name=’param’) please use param name. Cause hibernate will use this alias name instead of class name.

4. If all above not work for you so please use full qualified name for example com.devjav.SystemParameter instead SystemParameter

Convert CIDR notation to a list of IP addresses

In this post i will show you how to get all IPs that valid base on CIDR notation.

I use open source Apache Commons Net to write sample to list all IPs.

/*
 * devjav [http://devjav.com]
 * Copyright (C) 2014-2014 Pham Thai Thinh
 * Contact:phamthaithinh@gmail.com
 * 
 */
package com.flocash;

import org.apache.commons.net.util.SubnetUtils;

/**
 * 
 * @author Pham Thai Thinh
 * 
 */
public class IPgenerate {

  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    String subnet = "192.109.47.0/24";
    SubnetUtils utils = new SubnetUtils(subnet);
    String[] addresses = utils.getInfo().getAllAddresses();
    for (String ip : addresses) {
      System.out.println(ip);
    }
  }

}