The question is about how to handle data about entities, but not particularly useful to the entity itself. An example of such data may be the external script that controls the entity's behavior or the path to the animation file — such data is gathered when loading the entity and is no longer useful until you save the game; it certainly doesn't belong in the entity object. Any tips on how to handle metadata?
Put the data in an external file that gets loaded by the object factory. Both XML and JSON are very useful for this purpose:
Then when you save the game just save which entity it was (ie. the ID). When loading the saved game refer back to the entities data file:
ADDITION: Y'know, I think you may be overcomplicating things based on "it certainly doesn't belong in the entity object". If there is some information about the entity that your application needs to continually refer to then stick that information in the entity and provide a getter; if not, then don't.
If you really need/want it, provide one level of indirection; the EntityFactory class has information about what script to use when making intances of Entity. That is how I would design things for the use case I'm guessing you're getting at, since all Entity instances would reference the same script, but really it depends on your exact use case.
This statement actually gives me pause, and makes me think you may have a very unusual state serialization system. But, that said...
If you have a generic key/value dictionary type of storage for the data, you could simply hang a reference to that data off the entity object itself. It's fine that the entity knows that it has metadata, it's generally only problematic if the entity gets to know all about specific kinds of metadata.
(Of course that only matters if you've decided to let the specific metadata live above the level of abstraction of the entity itself, which it sounds like you have.)
Another option is to store the metadata dictionary elsewhere, perhaps in an interface whose job is to recover the metadata for a given entity given its entity ID or whatever.
Neither option is objectively better than the other in general; the latter tends to allow you to restrict what other systems have access to the metadata, which can be nice for enforcing your abstraction boundaries. The former tends to be easier to use. Which will be most ideal will depend more on your specific needs.