what's the use of persistence.xml ??

I saw only two following entries in the file, should I add a new entry for
club pojo ?

<class>org.appfuse.model.User</class>
<class>org.appfuse.model.Role</class>

I did try the following way:

In my club POJO, I have

@OneToMany
public Set<User> getUsers()
{
  return users;
}

in my user POJO, I have:

@ManyToOne
@JoinColumn(name="clubID")
public Club getClub()
{
    return club;
}

so the result is:

1) I have one column called "clubID" in user table
2) A table called "club_app_user" with two keys "Club_clubID", "users_id"
generated

but when I have saved the user record with "clubID" being saved successfully
in user table, nothing did happen in "club_app_user" , in other words, the
"club_app_user" still empty record, or do I need to save the record in
"club_app_user" explicitly ?


ros wrote:
> 
> Fan,
> 
> About 1) in pom.xml there should be 
> 
>         <dependency>
>             <groupId>org.appfuse</groupId>
>             <artifactId>appfuse-${web.framework}</artifactId>
>             <version>${appfuse.version}</version>
>             <type>warpath</type>
>             <exclusions>
>                 <!-- This exclusion and the dependency following this one
> allow DAO framework switching. -->
>                 <!-- You only need these if you want to use JPA or iBATIS.
> See APF-565 for more information. -->
>                 <!-- It does no harm to leave it in for Hibernate, but
> it's not needed. -->
>                 <exclusion>
>                     <groupId>org.appfuse</groupId>
>                     <artifactId>appfuse-hibernate</artifactId>
>                 </exclusion>
>             </exclusions>
>         </dependency>
>         <dependency>
>             <groupId>org.appfuse</groupId>
>             <artifactId>appfuse-${dao.framework}</artifactId>
>             <version>${appfuse.version}</version>
>             <exclusions>
>                 <exclusion>
>                     <groupId>org.appfuse</groupId>
>                     <artifactId>appfuse-data-common</artifactId>
>                 </exclusion>
>             </exclusions>
>         </dependency>
> 
> Check  / src  / main  / resources  / META-INF  / persistence.xml
> 
> 
> Fan wrote:
>> 
>> Hey ros:
>> 
>> 1)The original pom.xml already has the exclusion :
>> 
>> <dependency>
>>             <groupId>org.appfuse</groupId>
>>             <artifactId>appfuse-${web.framework}</artifactId>
>>             <version>${appfuse.version}</version>
>>             <type>warpath</type>
>>             <!-- This exclusion and the dependency following this one
>> allow DAO framework switching. -->
>>             <!-- You only need these if you want to use JPA or iBATIS.
>> See APF-565 for more information. -->
>>             <!-- It does no harm to leave it in for Hibernate, but it's
>> not needed. -->
>>             <exclusions>
>>                 <exclusion>
>>                     <groupId>org.appfuse</groupId>
>>                     <artifactId>appfuse-hibernate</artifactId>
>>                 </exclusion>
>>             </exclusions>
>> </dependency>
>> 
>> 2) what did you mean by "Then add in to your poroject User and Role pojos
>> at appfuse namespace" ?
>> 
>> 3) I did check the user pojo, it does has the foreign key club_clubID
>> 
>> 4) Yup, I am using M5
>> 
>> 5) I did include the bean definition in applicationContext.xml
>> 
>> <bean class="org.appfuse.dao.spring.HibernateExtensionPostProcessor"> 
>>         <property name="annotatedClasses"> 
>>             <list>
>>                 <value>com.smartclub.model.Club</value>
>>                 <value>com.smartclub.model.Facility</value>
>>             </list> 
>>         </property> 
>> </bean>
>> 
>> 6) I did include the mapping in hibernate.cfg.xml as well
>> 
>> <hibernate-configuration>
>>     <session-factory>
>>         <mapping class="org.appfuse.model.User"/>
>>         <mapping class="org.appfuse.model.Role"/>
>>         <mapping class="com.smartclub.model.Club"/>
>>         <mapping class="com.smartclub.model.Facility"/>
>>     </session-factory>
>> </hibernate-configuration>
>> 
>> 
>> What else I have to check ??
>> 
>> 
>> ros wrote:
>>> 
>>> Hi!
>>> 
>>> You have to exclude AppFuse Data Common Package in your pom.xml. Then
>>> add in to your poroject User and Role pojos at appfuse namespace (as
>>> described in http://www.appfuse.org/display/APF/AppFuse+Core+Classes)
>>> 
>>> Try to do  mvn clean compile hibernate3:hbm2ddl and check database for
>>> user table structure. If it does not contains fields defined in User
>>> pojo of your project then AppFuse Data Common Package is not excluded.
>>> 
>>> What is your version of appfuse, M5?
>>> 
>>> Regards,
>>> ros
>>> 
>>> 
>>> 
>>> Fan wrote:
>>>> 
>>>> Hey Ros:
>>>> 
>>>> I did add the related Object to both hibernate.cfg.xml and
>>>> applicationContext.xml. But it just does not work
>>>> 
>>>> Or do you mind to show me your hibernate.cfg.xml and
>>>> applicationContext.xml ? I afraid I might do it wrongly
>>>> 
>>>> Is that necessary to exclude the AppFuse Data Common Package ?
>>>> 
>>>> 
>>>> ros wrote:
>>>>> 
>>>>> Hi!
>>>>> 
>>>>> I resolve that by add my Contact object to both hibernate.cfg.xml and
>>>>> applicationContext.xml.
>>>>> 
>>>>> Reffer to http://www.appfuse.org/display/APF/AppFuse+Core+Classes
>>>>> 
>>>>> Hope this helps.
>>>>> 
>>>>> ros
>>>>> 
>>>>> 
>>>>> 
>>>>> Fan wrote:
>>>>>> 
>>>>>> Ros, 
>>>>>> 
>>>>>> What's the fix ? I am facing the same error as you did
>>>>>> 
>>>>>> 
>>>>>> ros wrote:
>>>>>>> 
>>>>>>> Right. Thanks Matt!
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/override-User-code-class-and-link-OneToMany-to-any-other-class-tf3217084s2369.html#a11432832
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to