[jbosstools-issues] [JBoss JIRA] Commented: (JBIDE-2077) "Make this class and its related classes mapped via JPA"

Max Rydahl Andersen (JIRA) jira-events at lists.jboss.org
Thu Sep 25 09:27:21 EDT 2008


    [ https://jira.jboss.org/jira/browse/JBIDE-2077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12431167#action_12431167 ] 

Max Rydahl Andersen commented on JBIDE-2077:
--------------------------------------------

Functionallity wise:

#0 This will be a *very* useful thing - I like that it follows associations automatically, and now that I can try it I think this is a feature we definitly want!

...but..

#1 JPA Tools is a menu name used by the Dali project - this entry should not be in there.
We should put this entry in the standard Source... submenu. (Call it "Add Hibernate/JPA annotations")

#2 It does not show any confirmation dialog to change the source.
I think it as a minimum should show which entities it will traverse/touch and ask the user to confirm it. (especially since there is no easy way of undoing it)

#3 optimally the user should be able to preview the changes in the standard Refactor/comparison view like e.g. Externalize strings does it.

#4 From first looks the generated annotations looks good, but will need some deeper tests

#5 if I have a public Product(String name) constructor a default protected constructor is not created - that should happen should it not ?

The following is comments to the code:

#5 Please stop doing "reverse if" comparisons i.e. (0 == x.compareTo(y)), use the standard everyone else does

#6 Don't use for( ; it.hasNext() ; ) when while(it.hasNext()) will work just as fine

#7 Plese put the code in an internal package - just like all the other things in the plugin

#8 Don't use ex.printStackTrace() in unittests. tests should have fail()/assert() for exceptions that should not happen or //ignore for exceptions 

#9 Don't use simple numbers to represent states, at least use constants/enumeration or a class to delegate the difference in behavior
i.e. 1 for has the import, 2 for the import is necessary makes no sense. Why not just a boolean ? If there are more than two states use a enumuration
RefEntityInfo also seem to cover alot of different responsibilities - not sure why that is not splitted up some more ? But at least use constants instead
of untyped char flags!

Do we really have to keep track of all those imports this way? i.e. just check for the import when generating instead of keeping track ?

#10 the unittest does not run:
java.lang.RuntimeException: Folder C:\work\os\jbosstools\trunk\hibernatetools\tests\org.hibernate.eclipse.jdt.ui.test\res\project/lib not found!
	at org.hibernate.eclipse.console.test.mappingproject.TestUtilsCommon.copyLibs(TestUtilsCommon.java:217)
	at org.hibernate.eclipse.jdt.ui.test.JPAMapTest.createTestProject(JPAMapTest.java:173)
	at org.hibernate.eclipse.jdt.ui.test.JPAMapTest.setUp(JPAMapTest.java:59)
	at junit.framework.TestCase.runBare(TestCase.java:128)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)




> "Make this class and its related classes mapped via JPA"
> --------------------------------------------------------
>
>                 Key: JBIDE-2077
>                 URL: https://jira.jboss.org/jira/browse/JBIDE-2077
>             Project: Tools (JBoss Tools)
>          Issue Type: Feature Request
>          Components: Hibernate
>            Reporter: Vitali Yemialyanchyk
>            Assignee: Vitali Yemialyanchyk
>            Priority: Minor
>             Fix For: 3.0.0.beta1
>
>         Attachments: JBIDE-2077_20080924.zip
>
>
> Denis Golovin:
> >>>
> Let's imagine I have several (say 10) classes that I'd like to make
> persistent. The classes form completed domain model.
> I decided to use hibernate and JPA annotations, I have lets say JBDS
> 1.1.0 or JBossTools 2.1.0 installed.
> Question is what I should do to make my model persistent? It there
> anything that helps me to do it?
> Now I see only way. I have to go through all classes and add annotations
> for class and for fields.
> >>>
> Max Andersen:
> >>>
> Having a "Make this class and its related classes mapped via JPA" would be 
> an interesting Refactoring to implement.
> Should basically just work like this:
> makePersistent(ITypeRoot clazz, Set processed) {
>   add @Entity 
>   Find most likely id property and add @Id  
>  processed.add(selectedClass);
>  associations = getAssociatedClasses(selectedClass);
>  foreach class in associations {
>   if(!processed.contains(class)) {
>        makePersistent(class, processed);     
>   }  
> }
> }
> There then might be some exceptional cases like handling version properties, temporal values and
> non-JPA supported mappings which Hibernate would be able to understand/map.
> >>>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jbosstools-issues mailing list