I have this simple code:
String tableName = MyEntity.class.getAnnotation( javax.persistence.Table.class ).name();
But IntelliJ underlines the fact that the method name()
does not exist Cannot resolve method "name()"
.
I also get this error during the compilation:
Error:(29, 68) java: cannot find symbol
symbol: method name()
location: interface java.lang.annotation.Annotation
I saw many example codes using this method, an example here: https://stackoverflow.com/a/1320890/6643803 What am I missing?
Thanks
As you can see here there is no name()
function inside the Annotation
interfaces
You probably need to cast it:
Table table = MyEntity.class.getAnnotation(javax.persistence.Table.class);
String tableName = table.name();
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.