For a year, tech companies have been hauled in front of congressional hearings to answer for a variety of scandals.

On Wednesday the dynamic was reversed, as they pushed lawmakers to pass a federal law that would protect them from having to comply with state privacy laws, in particular a strict new law in California.

Executives from Apple, Amazon, AT&T, Google, Twitter and Charter Communications appeared before the Senate Committee on Commerce, Science and Transportation in a hearing that highlighted how the discussion around data privacy and government regulation has changed.

Tech companies and internet service providers that spent years collecting reams of user data and flying under the radar of regulators have recently become a hot topic — and the subject of regulation. California’s data privacy law, which was passed in June, and Europe’s General Data Protection Regulation have pushed tech companies to turn to the federal government for a set of rules that are consistent and possibly more relaxed.

The fact that Silicon Valley is now seeking refuge in Congress wasn’t lost on lawmakers.

“You want something that you can work with, so that you don’t have to navigate 50 different statutory frameworks,” Sen. Brian Schatz, D-Hawaii, told the companies.

The “holy grail” of the companies, Schatz said, seemed to be overriding — or “pre-empting,” in legal terminology — state laws with a federal law. He warned, though, that the companies would have a difficult time getting everything they want, because privacy advocates might block a federal law if it doesn’t go far enough.

“We should make sure we do something meaningful,” he said.

Under questioning from Sen. Jerry Moran, R-Kan., representatives for the companies said one-by-one that they thought any federal data privacy bill should pre-empt state laws on the same subject.

“There is an increasing risk that we will end up with a patchwork quilt of inconsistent privacy regulations at the federal and state level, which will only serve to confuse consumers and stifle innovation,” wrote Leonard Cali, AT&T’s senior vice president of global public policy, in prepared testimony.

Andrew DeVore, vice president and associate general counsel at Amazon, also expressed concern that the California law was passed so quickly “there was little opportunity for thoughtful review” and there would be unintended consequences.

Though the California bill does not go into effect until 2020, the law has drawn the ire of a variety of companies and trade groups who have argued it is too broad and vague with its definition of personal data and the rules around the use of such data.

Some of the senators, however, were skeptical that the companies present were working in the best interest of consumers.

Sen. Richard Blumenthal, D-Conn., said the tech companies depend as businesses on access to people’s personal information, and said he wanted to know if the tech companies are sincere in trying to protect consumers in legislation.

“Some of you, let me be very blunt, fought the California law,” he said. “I am really seeking assurance that you will put your money where your mouth is.”

Sen. Catherine Cortez Masto, D-Nev., also questioned whether the core business models of tech companies were inherently at odds with data privacy.

“It's simply not possible for us to trust that your companies will make the changes needed to protect America's well-being and privacy,” Cortez Masto said.

Californians for Consumer Privacy, a group that advocated for that state’s new law, said Congress should follow California’s example as it has in some other regulatory matters such as auto emissions.

“To be clear: We will fight back against any attempts to undermine our state’s ability to provide these fundamental rights to California consumers, and will support further efforts to provide these rights to all Americans,” Alastair Mactaggart, the group’s chairman, said in a statement.

Still, the committee’s chairman, Sen. John Thune, R-S.D., said he saw a consensus forming that Congress should pass some form of data privacy legislation. To gather more feedback, he said the committee would hold another hearing next month with privacy advocates among the witnesses.