metadata - How to get the PC object's table name with Datanucleus v3.2? -
edit-this answer code mistakenly used editing metadata. reading it, use following:
pmf.getmetadata(machineclass.getname()).gettable()
i've been doing long time using previous datanucleus versions i'm not sure why isn't working anymore v3.2
this code doesn't work because getmetadataforclass
method returns null
!
nucleusjdohelper.getmetadataforclass(pmf, clazz).gettable()
where pmf persistencemanagerfactory
, clazz class<?>
object representing class type of pc (i.e. persistence capable) object need retrieve table name for.
i'm using annotations define mappings.
to create persistencemanagerfactory
, i'm using following code:
jdohelper.getpersistencemanagerfactory(new fileinputstream(filepath));
where filepath path properties
file enough data has been used long time without change.
edit: neil's answer, switched using following code sequence:
jdometadata md = pmf.newmetadata(); packagemetadata pmd = md.newpackagemetadata(clazz.getpackage()); classmetadata cmd = pmd.newclassmetadata(clazz); return cmd.gettable();
i made sure class i'm inspecting having proper metadata
@persistencecapable(table = "machine_table", detachable = "true", cacheable = "true") public class machine {
now cmd.gettable()
returns null
!
why use internal (unsupported?) api when jdo has had metadata api since jdo v2.x iirc? 1 here http://www.datanucleus.org/products/accessplatform_3_3/jdo/metadata_api.html
Comments
Post a Comment