Index: src/jaxme/org/apache/ws/jaxme/generator/sg/TypeSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/TypeSG.java,v
retrieving revision 1.6
diff -u -r1.6 TypeSG.java
--- src/jaxme/org/apache/ws/jaxme/generator/sg/TypeSG.java	9 Sep 2004 00:41:46 -0000	1.6
+++ src/jaxme/org/apache/ws/jaxme/generator/sg/TypeSG.java	12 Oct 2004 08:48:56 -0000
@@ -115,8 +115,8 @@
 
   /** <p>Generates a set method returning an instance of this type.</p>
    */
-  public JavaMethod getXMLSetMethod(JavaSource pSource,
-                                     String pFieldName, String pMethodName) throws SAXException;
+  public JavaMethod getXMLSetMethod(JavaSource pSource, String pFieldName,
+  		                            String pMethodName, boolean pSetIsSet) throws SAXException;
 
   /** <p>Generates an "isSet" method returning whether the field is set.</p>
    */
Index: src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBPropertySG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBPropertySG.java,v
retrieving revision 1.9
diff -u -r1.9 JAXBPropertySG.java
--- src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBPropertySG.java	2 Sep 2004 11:25:31 -0000	1.9
+++ src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBPropertySG.java	12 Oct 2004 08:48:56 -0000
@@ -140,7 +140,8 @@
 	
 	public JavaMethod getXMLSetMethod(PropertySG pController, JavaSource pSource) throws SAXException {
 		return typeSG.getXMLSetMethod(pSource, pController.getXMLFieldName(),
-				pController.getXMLSetMethodName());
+				                      pController.getXMLSetMethodName(),
+                                      pController.hasIsSetMethod());
 	}
 	
 	public JavaMethod getXMLIsSetMethod(PropertySG pController, JavaSource pSource) throws SAXException {
Index: src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBTypeSG.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBTypeSG.java,v
retrieving revision 1.11
diff -u -r1.11 JAXBTypeSG.java
--- src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBTypeSG.java	2 Oct 2004 00:39:56 -0000	1.11
+++ src/jaxme/org/apache/ws/jaxme/generator/sg/impl/JAXBTypeSG.java	12 Oct 2004 08:48:56 -0000
@@ -330,31 +330,40 @@
   }
 
   public JavaMethod getXMLSetMethod(TypeSG pController, JavaSource pSource,
-                                     String pFieldName, String pMethodName) throws SAXException {
-    if (pController.isComplex()) {
-      String pName = "p" + Character.toUpperCase(pFieldName.charAt(0)) + pFieldName.substring(1);
-      JavaMethod jm = pSource.newJavaMethod(pMethodName, JavaQNameImpl.VOID, JavaSource.PUBLIC);
-      JavaQName runtimeType;
-        if (pFieldName.equals("value") && pController.getComplexTypeSG().hasSimpleContent()) {
-          SimpleContentSG obj = pController.getComplexTypeSG().getSimpleContentSG();
-          runtimeType = obj.getContentTypeSG().getRuntimeType();
-          if (pController.isRestriction()) {
-            if (pController.getRestrictedType().isExtension()) {
-              runtimeType = pController.getRestrictedType().getExtendedType().getRuntimeType();
-            }
-          }
+  		                            String pFieldName, String pMethodName,
+                                    boolean pSetIsSet) throws SAXException {
+  	if (pController.isComplex()) {
+  		String pName = "p" + Character.toUpperCase(pFieldName.charAt(0)) + pFieldName.substring(1);
+  		JavaMethod jm = pSource.newJavaMethod(pMethodName, JavaQNameImpl.VOID, JavaSource.PUBLIC);
+  		JavaQName runtimeType;
+  		if (pFieldName.equals("value") && pController.getComplexTypeSG().hasSimpleContent()) {
+  			SimpleContentSG obj = pController.getComplexTypeSG().getSimpleContentSG();
+  			runtimeType = obj.getContentTypeSG().getRuntimeType();
+  			if (pController.isRestriction()) {
+  				if (pController.getRestrictedType().isExtension()) {
+  					runtimeType = pController.getRestrictedType().getExtendedType().getRuntimeType();
+  				}
+  			}
+  		}
+  		else {
+  			runtimeType = pController.getRuntimeType();
+  		}
+  		DirectAccessible param = jm.addParam(runtimeType, pName);
+  		if (!pSource.isInterface()) {
+  			jm.addLine(pFieldName, " = ", param, ";");
+  		}
+  		return jm;
+  	} else {
+  		JavaMethod jm = pController.getSimpleTypeSG().getXMLSetMethod(pSource, pFieldName, pMethodName);
+  		if (pSetIsSet  &&  pController.getRuntimeType().isPrimitive()) {
+  			jm.addLine(getIsSetCheckFieldName(pFieldName), " = true;");
         }
-        else {
-          runtimeType = pController.getRuntimeType();
-        }
-      DirectAccessible param = jm.addParam(runtimeType, pName);
-      if (!pSource.isInterface()) {
-        jm.addLine(pFieldName, " = ", param, ";");
-      }
-      return jm;
-    } else {
-      return pController.getSimpleTypeSG().getXMLSetMethod(pSource, pFieldName, pMethodName);
-    }
+        return jm;
+  	}
+  }
+
+  private String getIsSetCheckFieldName(String pFieldName) {
+  	return "has" + Character.toUpperCase(pFieldName.charAt(0)) + pFieldName.substring(1);
   }
 
   /** 
@@ -362,15 +371,13 @@
    * isSet and unset methods will be implemented by a flag and corresponding default value if it exist. 
    */
   public JavaMethod getXMLIsSetMethod(TypeSG pController, JavaSource pSource,
-    String pFieldName, String pMethodName) throws SAXException {
+  		                              String pFieldName, String pMethodName)
+      throws SAXException {
     JavaMethod jm = pSource.newJavaMethod(pMethodName, BooleanSG.BOOLEAN_TYPE, JavaSource.PUBLIC);
     if (!pSource.isInterface()) {
-      JavaQName checkQName = pController.getRuntimeType();
-      boolean isPrimitive = "".equals(checkQName.getPackageName());
-      if (isPrimitive) {
-        String checkFieldName = "has" + Character.toUpperCase(pFieldName.charAt(0)) + pFieldName.substring(1);
-        pSource.newJavaField(checkFieldName, BooleanSG.BOOLEAN_TYPE);
-        jm.addLine("return " + checkFieldName + ";");
+      if (pController.getRuntimeType().isPrimitive()) {
+      	JavaField jf = pSource.newJavaField(getIsSetCheckFieldName(pFieldName), BooleanSG.BOOLEAN_TYPE);
+        jm.addLine("return ", jf, ";");
       } else {
         jm.addLine("return (" + pFieldName + " != null);");
       }
Index: src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java,v
retrieving revision 1.3
diff -u -r1.3 JiraTest.java
--- src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java	11 Oct 2004 23:03:48 -0000	1.3
+++ src/jaxme/org/apache/ws/jaxme/junit/JiraTest.java	12 Oct 2004 08:48:56 -0000
@@ -8,6 +8,8 @@
 import org.apache.ws.jaxme.test.misc.types.impl.RowImpl;
 import org.xml.sax.InputSource;
 
+import magoffin.matt.ieat.domain.Ingredient;
+import magoffin.matt.ieat.domain.impl.IngredientImpl;
 import net.dspc.commons.activitymodel.TransmissionData;
 import net.dspc.commons.activitymodel2.Body1;
 import net.dspc.commons.activitymodel2.Body2;
@@ -80,5 +82,14 @@
         "  <ex:cell id=\"1\">a</ex:cell>\n" +
         "</ex:row>";
         unmarshalMarshalUnmarshal(Row.class, xml);
+    }
+
+    /** Test for <a href="http://nagoya.apache.org/jira/browse/JAXME-39">JAXME-39</a>
+     */
+    public void testJaxMe39() throws Exception {
+    	IngredientImpl ingredientImpl = new IngredientImpl();
+        assertTrue(!ingredientImpl.isSetIngredientId());
+        ingredientImpl.setIngredientId(new Integer(0));
+        assertTrue(ingredientImpl.isSetIngredientId());
     }
 }
