简体   繁体   中英

Generating Entity class from Column Family Definition

I'm trying to generate the entity class for a Cassandra column family from the column family definition (a .cql file), programmatically.

To achieve that I've used the arch4j java code generator . But, unfortunately, I didn't find any solution to create annotations using this API. So, I used Javassist to add annotations to the generated entity class. Again, as this Javassist API deals with the Java byte code, I had to use a Java decompiler (eg Procyon) to decompile the class file generated by Javassist.

Is there any simpler way to achieve my target?

Well, I took another approach towards solving my problem and ended up with JavaPoet and Project Lombok APIs. I've used JavaPoet to generate the .java file with the required annotations for the entity. Then I've processed that file using Lombok/Delombok to generate the getters, setters, hashCode, equals and toString methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM