Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[dali-dev] JPA contex model refresh

Title: JPA contex model refresh

Hello colleagues,

 I am writing a junit test in which I create an IFile with content looking something like this

String content = "package " + packageName + ";\n\n"
                                        + "import javax.persistence.*;\n\n"
                                        + "@Entity \n"
                                        + "public class " + entityShortName + " {\n"
                                        + "     @Id \n"                                
                                        + "     private int id;\n"
                                        + "     public int getId() {\n"
                                        + "             return id;\n"
                                        + "     }\n"
                                        + "     public void setId(int id) {\n"
                                        + "             this.id = id;\n"
                                        + "     }\n"
                                        + "}"; //$NON-NLS-1$

Then I try to acquire the PersistenType using

for (Iterator<JpaStructureNode> i = jpaFile.rootStructureNodes(); i.hasNext(); ) {
                        JpaStructureNode node = i.next();
                        if(node instanceof JavaPersistentType){
                                JavaPersistentType entity = (JavaPersistentType) node;
                                return entity;
                        }
                }

On some occasions the returned result is null.

My question is - is there a way to make sure that the context jpa model is refreshed, or if I can get the JavaPersistentType in some other way, that will ensure I will receive constant results.

Thanks in advance,
Milen


Back to the top