diff --git a/src/php/Metadata/MetadataFactory.php b/src/php/Metadata/MetadataFactory.php
index 4e208e011ff5f22874c15b852f89bdb858206e4e..e5650d1feb4b1cbb6eb4c3f2b037bc0014421dc4 100644
--- a/src/php/Metadata/MetadataFactory.php
+++ b/src/php/Metadata/MetadataFactory.php
@@ -416,9 +416,11 @@ final class MetadataFactory implements MetadataFactoryInterface
                 $properties[$propertyName] = $property;
                 if ($property->isEmbedded()) {
                     $type = $property->getLeafType();
-                    $className = $type->getClassName();
-                    if ($className) {
-                        $queue[] = PHPClass::get($className);
+                    if ($type) {
+                        $className = $type->getClassName();
+                        if ($className) {
+                            $queue[] = PHPClass::get($className);
+                        }
                     }
                 }
             }
@@ -427,7 +429,7 @@ final class MetadataFactory implements MetadataFactoryInterface
 
             $abstract = (new \ReflectionClass($current->getFullName()))->isAbstract();
 
-            $representations[$current->getFullName()] = new RepresentationMetadata($name, $current, $parent, $properties, $abstract);
+            $representations[$current->getFullName()] = new RepresentationMetadata($name, $current, $parent, $properties, $abstract, $this->isResource($current));
         }
 
         return new SerializationMetadata($class, $groups, $normalization, $representations);
diff --git a/src/php/Metadata/RepresentationMetadata.php b/src/php/Metadata/RepresentationMetadata.php
index e2021537ff6ba94b97b4832f65987ee2e034e5a9..14e49d91249f356981b340aa0f6d91f85e09cab8 100644
--- a/src/php/Metadata/RepresentationMetadata.php
+++ b/src/php/Metadata/RepresentationMetadata.php
@@ -55,6 +55,9 @@ final class RepresentationMetadata implements ClassName, HasName
      */
     private $abstract;
 
+    /** @var bool */
+    private $resource;
+
     /**
      * RepresentationMetadata constructor.
      *
@@ -63,7 +66,7 @@ final class RepresentationMetadata implements ClassName, HasName
      * @param ClassName|null     $parent
      * @param PropertyMetadata[] $properties
      */
-    public function __construct(string $name, ClassName $class, ?ClassName $parent, array $properties, bool $abstract)
+    public function __construct(string $name, ClassName $class, ?ClassName $parent, array $properties, bool $abstract, bool $resource)
     {
         if ($parent && $class->getFullName() === $parent->getFullName()) {
             throw new DomainException("$class cannot be its own parent");
@@ -79,6 +82,7 @@ final class RepresentationMetadata implements ClassName, HasName
 
         $this->name = $name;
         $this->abstract = $abstract;
+        $this->resource = $resource;
     }
 
     /**
@@ -153,6 +157,16 @@ final class RepresentationMetadata implements ClassName, HasName
         return $this->abstract;
     }
 
+    /**
+     * Get resource.
+     *
+     * @return bool
+     */
+    public function isResource(): bool
+    {
+        return $this->resource;
+    }
+
     /**
      * {@inheritdoc}
      */
diff --git a/src/php/Models/ClassInfo.php b/src/php/Models/ClassInfo.php
index b6c93e869d35a76b0229b8070edba76c48f31326..066a146517993d78a4d323cb5452d6e66efc9c96 100644
--- a/src/php/Models/ClassInfo.php
+++ b/src/php/Models/ClassInfo.php
@@ -55,14 +55,18 @@ final class ClassInfo implements ClassName
     /** @var bool */
     private $abstract;
 
+    /** @var bool */
+    private $resource;
+
     /**
      * ClassInfo constructor.
      *
-     * @param ClassName          $class
+     * @param ClassName $class
      * @param PropertyMetadata[] $properties
-     * @param bool               $abstract
+     * @param bool $abstract
+     * @param bool $resource
      */
-    public function __construct(ClassName $class, array $properties = [], bool $abstract = false)
+    public function __construct(ClassName $class, array $properties = [], bool $abstract = false, bool $resource = false)
     {
         $this->class = $class;
         $this->abstract = $abstract;
@@ -71,6 +75,7 @@ final class ClassInfo implements ClassName
             $this->virtualProperties[$property->getName()] = $property;
         }
         $this->concreteProperties = $abstract ? [] : $this->virtualProperties;
+        $this->resource = $resource;
     }
 
     /**
@@ -127,6 +132,16 @@ final class ClassInfo implements ClassName
         return $this->abstract;
     }
 
+    /**
+     * Get resource.
+     *
+     * @return bool
+     */
+    public function isResource(): bool
+    {
+        return $this->resource;
+    }
+
     /**
      * Get parent.
      *
diff --git a/src/php/SerializationMapper.php b/src/php/SerializationMapper.php
index 5614fbdedc8d600f77dd16b91d5fd671d5e5bce4..cdbaacecb47be99137669605e14c121e03fbeae1 100644
--- a/src/php/SerializationMapper.php
+++ b/src/php/SerializationMapper.php
@@ -254,7 +254,7 @@ final class SerializationMapper implements TypeFactoryInterface
             );
         }
 
-        if ($this->withAtFields && $identifierCount > 0) {
+        if ($this->withAtFields && $classInfo->isResource()) {
             $properties['@id'] = new Property(
                 '@id',
                 '',
@@ -374,7 +374,8 @@ final class SerializationMapper implements TypeFactoryInterface
             $this->classInfo[$className] = new ClassInfo(
                 $repr,
                 $repr->getProperties(),
-                $repr->isAbstract()
+                $repr->isAbstract(),
+                $repr->isResource()
             );
         }