It is not anti-democratic for the CJEU to set limits to the democratic power of the EU, when the CJEU does so to protect the democratic power of the individual states.
The EU is a union of democratic member states. This is a hard criterion; it's the first of the Copenhagen criteria on candidate EU member members. It's also a union of sovereign states. If any country finds continued EU membership irrevocably at odds with national interests, Article 50 gives them the right to withdraw from the EU; Brexit is a clear example.
Yet the EU is more than a simple treaty between sovereign states. It is effectively a government on its own, with its own democratic institutes. And in many areas, but not all, the EU has supremacy over the legislation of its members.
As a result, the question which parliament is supreme depends on the area of legislation, and the border is not always clear-cut. At that point, it is up to the CJEU to decide which parliament gets to decide, but either way the CJEU itself does not write the legislation.